I'm using neovim to edit my LaTeX and python projects, using packer to be my plugin manager. I'm trying to use lsp along with ultisnips to autocomplete, and for now the ultisnips works very well but lsp doesn't work. Here is my configures.
-- lsp.lua
require("mason").setup({
ui = {
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗"
}
}
})
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"clangd",
"jsonls",
-- "ltex",
-- "texlab",
"pylsp",
-- "pylyzer",
"vimls"
}
})
local capabilities = require('cmp_nvim_lsp').default_capabilities()
require("lspconfig").lua_ls.setup {
capabilities = capabilities,
}
-- cmp.lua
local cmp = require'cmp'
local cmp_ultisnips_mappings = require'cmp_nvim_ultisnips.mappings'
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
cmp.setup({
preselect = cmp.PreselectMode.None,
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
-- cmp.confirm({ select = true })
else
cmp_ultisnips_mappings.jump_forwards(fallback)
end
end, { 'i', 's' }),
-- ["<Tab>"] = cmp.mapping({
-- i = function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
-- else
-- cmp_ultisnips_mappings.jump_forwards(fallback)
-- end
-- end,
-- }),
-- ["<Tab>"] = cmp.mapping({
-- c = function()
-- if cmp.visible() then
-- cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
-- else
-- cmp.complete()
-- end
-- end,
-- i = function(fallback)
-- if cmp.visible() and vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
-- vim.api.nvim_feedkeys(t("<Plug>(ultisnips_jump_forward)"), 'm', true)
-- elseif cmp.visible() then
-- cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
-- elseif vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
-- vim.api.nvim_feedkeys(t("<Plug>(ultisnips_jump_forward)"), 'm', true)
-- else
-- fallback()
-- end
-- end,
-- s = function(fallback)
-- if vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
-- vim.api.nvim_feedkeys(t("<Plug>(ultisnips_jump_forward)"), 'm', true)
-- else
-- fallback()
-- end
-- end
-- }),
['<S-tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
cmp_ultisnips_mappings.jump_backwards(fallback)
end
end, { 'i', 's' }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'ultisnips' },
{ name = 'path' },
}, {
{ name = 'buffer', keyword_length = 5},
}),
})
-- plugins-setup.lua
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
vim.cmd([[
augroup pacer_user_config
autocmd!
autocmd BufWritePost plugins-setup.lua source <afile> | PackerSync
augroup end
]])
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use 'EdenEast/nightfox.nvim'
use {
'nvim-lualine/lualine.nvim',
requires = { 'nvim-tree/nvim-web-devicons', opt = true }
}
use 'nvim-tree/nvim-web-devicons'
use {
'nvim-tree/nvim-tree.lua',
requires = {
'nvim-tree/nvim-web-devicons', -- optional
}
}
use("christoomey/vim-tmux-navigator")
use("nvim-treesitter/nvim-treesitter")
use("p00f/nvim-ts-rainbow")
use{
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
"mfussenegger/nvim-dap",
"jose-elias-alvarez/null-ls.nvim"
}
use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lua"
use "hrsh7th/cmp-path"
use "numToStr/Comment.nvim"
use "windwp/nvim-autopairs"
use "akinsho/bufferline.nvim"
use "lewis6991/gitsigns.nvim"
use {
'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = { {
'nvim-lua/plenary.nvim',
'BurntSushi/ripgrep',
'sharkdp/fd'
} }
}
-- Lua
use {
"folke/which-key.nvim",
config = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
require("which-key").setup {}
end
}
use 'lervag/vimtex'
-- use 'ybian/smartim'
use 'SirVer/ultisnips'
use "quangnguyen30192/cmp-nvim-ultisnips"
if packer_bootstrap then
require('packer').sync()
end
end)
I believe that there is something I didn't open or just not install. How can I fix this? Or how can I debug to locate the problem?