move from compe to cmp

This commit is contained in:
Barak Michener 2024-06-03 18:05:16 -07:00
parent 6fb63aa116
commit 4a28478156
2 changed files with 68 additions and 119 deletions

View file

@ -2,6 +2,7 @@ require('nvim-autopairs').setup {}
-- nvim_lsp object -- nvim_lsp object
local nvim_lsp = require 'lspconfig' local nvim_lsp = require 'lspconfig'
require('cmp_setup')
-- function to attach completion when setting up lsp -- function to attach completion when setting up lsp
local on_attach = function(client) local on_attach = function(client)
@ -14,16 +15,17 @@ local diagnostic_options = {
update_in_insert = false, update_in_insert = false,
} }
local rust_capabilities = vim.lsp.protocol.make_client_capabilities() --local rust_capabilities = vim.lsp.protocol.make_client_capabilities()
rust_capabilities.textDocument.completion.completionItem.snippetSupport = true --rust_capabilities.textDocument.completion.completionItem.snippetSupport = true
rust_capabilities.textDocument.completion.completionItem.resolveSupport = { --rust_capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = { --properties = {
'documentation', --'documentation',
'detail', --'detail',
'additionalTextEdits', --'additionalTextEdits',
} --}
} --}
--local default_capabilities = vim.lsp.protocol.make_client_capabilities()
local default_capabilities = vim.lsp.protocol.make_client_capabilities() local default_capabilities = vim.lsp.protocol.make_client_capabilities()
default_capabilities.textDocument.completion.completionItem.snippetSupport = true default_capabilities.textDocument.completion.completionItem.snippetSupport = true
default_capabilities.textDocument.completion.completionItem.resolveSupport = { default_capabilities.textDocument.completion.completionItem.resolveSupport = {
@ -33,13 +35,14 @@ default_capabilities.textDocument.completion.completionItem.resolveSupport = {
'additionalTextEdits', 'additionalTextEdits',
} }
} }
default_capabilities = require('cmp_nvim_lsp').default_capabilities(default_capabilities)
-- Enable rust_analyzer -- Enable rust_analyzer
nvim_lsp.rust_analyzer.setup({ nvim_lsp.rust_analyzer.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
client.server_capabilities.semanticTokensProvider = nil client.server_capabilities.semanticTokensProvider = nil
end, end,
capabilities = rust_capabilities, capabilities = default_capabilities,
settings = { settings = {
['rust-analyzer'] = { ['rust-analyzer'] = {
checkOnSave = { checkOnSave = {
@ -70,6 +73,7 @@ nvim_lsp.gopls.setup({
} }
} }
end, end,
capabilities = default_capabilities,
settings = { settings = {
gopls = { gopls = {
semanticTokens = true, semanticTokens = true,
@ -114,7 +118,8 @@ end
nvim_lsp.pyright.setup({ nvim_lsp.pyright.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(pyright_custom_diagnostic, diagnostic_options) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(pyright_custom_diagnostic, diagnostic_options)
end end,
capabilities = default_capabilities,
}) })
--nvim_lsp.pyright.setup({ on_attach = on_attach }) --nvim_lsp.pyright.setup({ on_attach = on_attach })
--nvim_lsp.pylsp.setup({ --nvim_lsp.pylsp.setup({
@ -153,26 +158,30 @@ nvim_lsp.pyright.setup({
--} --}
--}) --})
nvim_lsp.clangd.setup({ on_attach = on_attach }) nvim_lsp.clangd.setup { on_attach = on_attach, capabilities = default_capabilities }
nvim_lsp.tsserver.setup { nvim_lsp.tsserver.setup {
cmd = { "/home/barak/.yarn/bin/typescript-language-server", "--stdio" } cmd = { "/home/barak/.yarn/bin/typescript-language-server", "--stdio" }
} }
nvim_lsp.vuels.setup { nvim_lsp.vuels.setup {
cmd = { "/home/barak/.yarn/bin/vls" } cmd = { "/home/barak/.yarn/bin/vls" },
capabilities = default_capabilities,
} }
nvim_lsp.hls.setup { nvim_lsp.hls.setup {
cmd = { "haskell-language-server-wrapper", "--lsp" } cmd = { "haskell-language-server-wrapper", "--lsp" },
capabilities = default_capabilities,
} }
nvim_lsp.svelte.setup { nvim_lsp.svelte.setup {
cmd = { "/home/barak/.bun/bin/bunx", "svelteserver", "--stdio" } cmd = { "/home/barak/.bun/bin/bunx", "svelteserver", "--stdio" },
capabilities = default_capabilities,
} }
local runtime_path = vim.split(package.path, ';') local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua") table.insert(runtime_path, "lua/?/init.lua")
require 'lspconfig'.lua_ls.setup { nvim_lsp.lua_ls.setup {
capabilities = default_capabilities,
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {
@ -248,7 +257,7 @@ local efmls_config = {
}, },
} }
require('lspconfig').efm.setup(vim.tbl_extend('force', efmls_config, { nvim_lsp.efm.setup(vim.tbl_extend('force', efmls_config, {
-- Pass your custom lsp config below like on_attach and capabilities -- Pass your custom lsp config below like on_attach and capabilities
on_attach = on_attach, on_attach = on_attach,
capabilities = default_capabilities, capabilities = default_capabilities,
@ -260,27 +269,6 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
diagnostic_options diagnostic_options
) )
-- Compe setup
require 'compe'.setup {
enabled = true,
autocomplete = true,
debug = false,
min_length = 1,
preselect = 'disable',
throttle_time = 80,
source_timeout = 200,
incomplete_delay = 400,
max_abbr_width = 100,
max_kind_width = 100,
max_menu_width = 100,
documentation = true,
source = {
path = true,
nvim_lsp = true,
},
}
--signature_cfg = { --signature_cfg = {
--hint_enable = true, --hint_enable = true,
--hint_prefix = "% ", --hint_prefix = "% ",
@ -316,68 +304,28 @@ end
-- Use (s-)tab to: -- Use (s-)tab to:
--- move to prev/next item in completion menuone --- move to prev/next item in completion menuone
--- jump to prev/next snippet's placeholder --- jump to prev/next snippet's placeholder
_G.tab_complete = function() --_G.tab_complete = function()
if vim.fn.pumvisible() == 1 then --if vim.fn.pumvisible() == 1 then
return t "<C-n>" --return t "<C-n>"
elseif check_back_space() then --elseif check_back_space() then
return t "<Tab>" --return t "<Tab>"
else --else
return vim.fn['compe#complete']() --return vim.fn['compe#complete']()
end --end
end --end
_G.s_tab_complete = function() --_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then --if vim.fn.pumvisible() == 1 then
return t "<C-p>" --return t "<C-p>"
else --else
return t "<S-Tab>" --return t "<S-Tab>"
end --end
end --end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true }) --vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true })
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true }) --vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true })
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) --vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) --vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true })
require('lspkind').init({
-- disables text annotations
--with_text = false,
--with_text = true,
-- defines how annotations are shown
-- default: symbol
-- options: 'text', 'text_symbol', 'symbol_text', 'symbol'
mode = 'symbol',
-- default symbol map
-- can be either 'default' or 'codicons'
preset = 'default',
-- override preset symbols
-- default: {}
--symbol_map = {
--Method = 'm',
--Function = 'f',
--Text = 'txt',
--Constructor = 'new',
--Variable = 'var',
--Class = 'cls',
--Interface = 'iface',
--Module = 'mod',
--Property = 'prop',
--Unit = 'unit',
--Value = 'val',
--Enum = 'enum',
--Keyword = 'kw',
--Snippet = 'sn',
--Color = 'color',
--File = 'file',
--Folder = 'fold',
--EnumMember = 'enum',
--Constant = 'const',
--Struct = 'struct',
--},
})
--require('rust-tools').setup({ --require('rust-tools').setup({
--}) --})
@ -385,26 +333,26 @@ require('lspkind').init({
require('trouble').setup { require('trouble').setup {
mode = "document_diagnostics", mode = "document_diagnostics",
auto_close = true, auto_close = true,
action_keys = { -- key mappings for actions in the trouble list action_keys = { -- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example: -- map to {} to remove a mapping, for example:
-- close = {}, -- close = {},
--close = "q", -- close the list --close = "q", -- close the list
--cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor --cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
--refresh = "r", -- manually refresh --refresh = "r", -- manually refresh
jump = { "o", "<tab>" }, -- jump to the diagnostic or open / close folds jump = { "o", "<tab>" }, -- jump to the diagnostic or open / close folds
--open_split = { "<c-x>" }, -- open buffer in new split --open_split = { "<c-x>" }, -- open buffer in new split
--open_vsplit = { "<c-v>" }, -- open buffer in new vsplit --open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = {}, -- open buffer in new tab open_tab = {}, -- open buffer in new tab
jump_close = { "<cr>" }, -- jump to the diagnostic and close the list jump_close = { "<cr>" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
toggle_preview = "P", -- toggle auto_preview toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location preview = "p", -- preview the diagnostic location
close_folds = { "zM", "zm" }, -- close all folds close_folds = { "zM", "zm" }, -- close all folds
open_folds = { "zR", "zr" }, -- open all folds open_folds = { "zR", "zr" }, -- open all folds
toggle_fold = { "zA", "za" }, -- toggle fold of current file toggle_fold = { "zA", "za" }, -- toggle fold of current file
previous = "k", -- previous item previous = "k", -- previous item
next = "j" -- next item next = "j" -- next item
}, },
} }
@ -556,8 +504,8 @@ require 'nvim-treesitter.configs'.setup {
playground = { playground = {
enable = true, enable = true,
disable = {}, disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false, -- Whether the query persists across vim sessions persist_queries = false, -- Whether the query persists across vim sessions
keybindings = { keybindings = {
toggle_query_editor = 'o', toggle_query_editor = 'o',
toggle_hl_groups = 'i', toggle_hl_groups = 'i',

View file

@ -157,6 +157,7 @@ Plug 'airblade/vim-rooter'
Plug 'majutsushi/tagbar' Plug 'majutsushi/tagbar'
"Plug 'SirVer/ultisnips' "Plug 'SirVer/ultisnips'
Plug 'dcampos/nvim-snippy' Plug 'dcampos/nvim-snippy'
Plug 'dcampos/cmp-snippy'
Plug 'rafamadriz/friendly-snippets' Plug 'rafamadriz/friendly-snippets'
Plug 'honza/vim-snippets' Plug 'honza/vim-snippets'
@ -219,7 +220,12 @@ Plug 'cappyzawa/starlark.vim'
"Plug 'romainl/vim-qf' "Plug 'romainl/vim-qf'
Plug 'neovim/nvim-lspconfig' Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/lsp_extensions.nvim' Plug 'nvim-lua/lsp_extensions.nvim'
Plug 'hrsh7th/nvim-compe' Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
"Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
"Plug 'hrsh7th/nvim-compe'
"Plug 'nvim-lua/completion-nvim' "Plug 'nvim-lua/completion-nvim'
Plug 'onsails/lspkind-nvim' Plug 'onsails/lspkind-nvim'
@ -339,11 +345,6 @@ let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
let g:completion_matching_smart_case = 1 let g:completion_matching_smart_case = 1
let g:completion_sorting = 'length' let g:completion_sorting = 'length'
inoremap <silent><expr> <CR> compe#confirm('<CR>')
inoremap <silent><expr> <C-e> compe#close('<C-e>')
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
" **** End LSP " **** End LSP