move from compe to cmp
This commit is contained in:
parent
6fb63aa116
commit
4a28478156
2 changed files with 68 additions and 119 deletions
174
dot_vim/nvim.lua
174
dot_vim/nvim.lua
|
|
@ -2,6 +2,7 @@ require('nvim-autopairs').setup {}
|
|||
|
||||
-- nvim_lsp object
|
||||
local nvim_lsp = require 'lspconfig'
|
||||
require('cmp_setup')
|
||||
|
||||
-- function to attach completion when setting up lsp
|
||||
local on_attach = function(client)
|
||||
|
|
@ -14,16 +15,17 @@ local diagnostic_options = {
|
|||
update_in_insert = false,
|
||||
}
|
||||
|
||||
local rust_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
rust_capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
rust_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = {
|
||||
'documentation',
|
||||
'detail',
|
||||
'additionalTextEdits',
|
||||
}
|
||||
}
|
||||
--local rust_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
--rust_capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
--rust_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
--properties = {
|
||||
--'documentation',
|
||||
--'detail',
|
||||
--'additionalTextEdits',
|
||||
--}
|
||||
--}
|
||||
|
||||
--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.resolveSupport = {
|
||||
|
|
@ -33,13 +35,14 @@ default_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|||
'additionalTextEdits',
|
||||
}
|
||||
}
|
||||
default_capabilities = require('cmp_nvim_lsp').default_capabilities(default_capabilities)
|
||||
|
||||
-- Enable rust_analyzer
|
||||
nvim_lsp.rust_analyzer.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
client.server_capabilities.semanticTokensProvider = nil
|
||||
end,
|
||||
capabilities = rust_capabilities,
|
||||
capabilities = default_capabilities,
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
checkOnSave = {
|
||||
|
|
@ -70,6 +73,7 @@ nvim_lsp.gopls.setup({
|
|||
}
|
||||
}
|
||||
end,
|
||||
capabilities = default_capabilities,
|
||||
settings = {
|
||||
gopls = {
|
||||
semanticTokens = true,
|
||||
|
|
@ -114,7 +118,8 @@ end
|
|||
nvim_lsp.pyright.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
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.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 {
|
||||
cmd = { "/home/barak/.yarn/bin/typescript-language-server", "--stdio" }
|
||||
}
|
||||
nvim_lsp.vuels.setup {
|
||||
cmd = { "/home/barak/.yarn/bin/vls" }
|
||||
cmd = { "/home/barak/.yarn/bin/vls" },
|
||||
capabilities = default_capabilities,
|
||||
}
|
||||
nvim_lsp.hls.setup {
|
||||
cmd = { "haskell-language-server-wrapper", "--lsp" }
|
||||
cmd = { "haskell-language-server-wrapper", "--lsp" },
|
||||
capabilities = default_capabilities,
|
||||
}
|
||||
|
||||
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, ';')
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
require 'lspconfig'.lua_ls.setup {
|
||||
nvim_lsp.lua_ls.setup {
|
||||
capabilities = default_capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
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
|
||||
on_attach = on_attach,
|
||||
capabilities = default_capabilities,
|
||||
|
|
@ -260,27 +269,6 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
|||
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 = {
|
||||
--hint_enable = true,
|
||||
--hint_prefix = "% ",
|
||||
|
|
@ -316,68 +304,28 @@ end
|
|||
-- Use (s-)tab to:
|
||||
--- move to prev/next item in completion menuone
|
||||
--- jump to prev/next snippet's placeholder
|
||||
_G.tab_complete = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return t "<C-n>"
|
||||
elseif check_back_space() then
|
||||
return t "<Tab>"
|
||||
else
|
||||
return vim.fn['compe#complete']()
|
||||
end
|
||||
end
|
||||
--_G.tab_complete = function()
|
||||
--if vim.fn.pumvisible() == 1 then
|
||||
--return t "<C-n>"
|
||||
--elseif check_back_space() then
|
||||
--return t "<Tab>"
|
||||
--else
|
||||
--return vim.fn['compe#complete']()
|
||||
--end
|
||||
--end
|
||||
|
||||
_G.s_tab_complete = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return t "<C-p>"
|
||||
else
|
||||
return t "<S-Tab>"
|
||||
end
|
||||
end
|
||||
--_G.s_tab_complete = function()
|
||||
--if vim.fn.pumvisible() == 1 then
|
||||
--return t "<C-p>"
|
||||
--else
|
||||
--return t "<S-Tab>"
|
||||
--end
|
||||
--end
|
||||
|
||||
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("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 })
|
||||
|
||||
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',
|
||||
--},
|
||||
})
|
||||
--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("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 })
|
||||
|
||||
--require('rust-tools').setup({
|
||||
--})
|
||||
|
|
@ -385,26 +333,26 @@ require('lspkind').init({
|
|||
require('trouble').setup {
|
||||
mode = "document_diagnostics",
|
||||
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:
|
||||
-- close = {},
|
||||
--close = "q", -- close the list
|
||||
--cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
|
||||
--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_vsplit = { "<c-v>" }, -- open buffer in new vsplit
|
||||
open_tab = {}, -- open buffer in new tab
|
||||
jump_close = { "<cr>" }, -- jump to the diagnostic and close the list
|
||||
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
|
||||
toggle_preview = "P", -- toggle auto_preview
|
||||
hover = "K", -- opens a small popup with the full multiline message
|
||||
preview = "p", -- preview the diagnostic location
|
||||
close_folds = { "zM", "zm" }, -- close all folds
|
||||
open_folds = { "zR", "zr" }, -- open all folds
|
||||
toggle_fold = { "zA", "za" }, -- toggle fold of current file
|
||||
previous = "k", -- previous item
|
||||
next = "j" -- next item
|
||||
open_tab = {}, -- open buffer in new tab
|
||||
jump_close = { "<cr>" }, -- jump to the diagnostic and close the list
|
||||
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
|
||||
toggle_preview = "P", -- toggle auto_preview
|
||||
hover = "K", -- opens a small popup with the full multiline message
|
||||
preview = "p", -- preview the diagnostic location
|
||||
close_folds = { "zM", "zm" }, -- close all folds
|
||||
open_folds = { "zR", "zr" }, -- open all folds
|
||||
toggle_fold = { "zA", "za" }, -- toggle fold of current file
|
||||
previous = "k", -- previous item
|
||||
next = "j" -- next item
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -556,8 +504,8 @@ require 'nvim-treesitter.configs'.setup {
|
|||
playground = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
|
||||
persist_queries = false, -- Whether the query persists across vim sessions
|
||||
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
|
||||
persist_queries = false, -- Whether the query persists across vim sessions
|
||||
keybindings = {
|
||||
toggle_query_editor = 'o',
|
||||
toggle_hl_groups = 'i',
|
||||
|
|
|
|||
13
dot_vimrc
13
dot_vimrc
|
|
@ -157,6 +157,7 @@ Plug 'airblade/vim-rooter'
|
|||
Plug 'majutsushi/tagbar'
|
||||
"Plug 'SirVer/ultisnips'
|
||||
Plug 'dcampos/nvim-snippy'
|
||||
Plug 'dcampos/cmp-snippy'
|
||||
Plug 'rafamadriz/friendly-snippets'
|
||||
|
||||
Plug 'honza/vim-snippets'
|
||||
|
|
@ -219,7 +220,12 @@ Plug 'cappyzawa/starlark.vim'
|
|||
"Plug 'romainl/vim-qf'
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
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 '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_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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue