LSP nvim stuff
This commit is contained in:
parent
82bceebbfd
commit
1d7acb6a57
4 changed files with 114 additions and 99 deletions
|
@ -64,13 +64,8 @@ local keymap = {
|
||||||
['ib'] = { '<Plug>CamelCaseMotion_ib', m.s },
|
['ib'] = { '<Plug>CamelCaseMotion_ib', m.s },
|
||||||
['ie'] = { '<Plug>CamelCaseMotion_ie', m.s },
|
['ie'] = { '<Plug>CamelCaseMotion_ie', m.s },
|
||||||
},
|
},
|
||||||
c = {
|
|
||||||
['<c-n>'] = '<down>',
|
|
||||||
['<c-p>'] = '<up>',
|
|
||||||
},
|
|
||||||
i = {
|
i = {
|
||||||
['<c-q>'] = '<esc><c-q>',
|
['<c-q>'] = '<esc><c-q>',
|
||||||
['<c-n>'] = {'<Plug>(completion_trigger)', m.s},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for mode, mappings in pairs(keymap) do
|
for mode, mappings in pairs(keymap) do
|
||||||
|
|
|
@ -31,11 +31,12 @@ local on_attach = function(client, bufnr)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting_seq_sync()<CR>', opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local capabilities = require 'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
local common_config = {
|
local common_config = {
|
||||||
capabilities = require'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
flags = {
|
flags = {
|
||||||
debounce_text_changes = 150
|
debounce_text_changes = 150
|
||||||
|
@ -46,6 +47,12 @@ local lsp_configs = {
|
||||||
gopls = {},
|
gopls = {},
|
||||||
elixirls = {
|
elixirls = {
|
||||||
cmd = { vim.fn.expand '~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' },
|
cmd = { vim.fn.expand '~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' },
|
||||||
|
settings = {
|
||||||
|
elixirLS = {
|
||||||
|
dialyzerEnabled = true,
|
||||||
|
fetchDeps = false,
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
sumneko_lua = {
|
sumneko_lua = {
|
||||||
settings = {
|
settings = {
|
||||||
|
|
|
@ -22,7 +22,7 @@ packer.startup(function()
|
||||||
'christoomey/vim-tmux-navigator', -- navigate vim splits and tmux panes fluidly
|
'christoomey/vim-tmux-navigator', -- navigate vim splits and tmux panes fluidly
|
||||||
'machakann/vim-sandwich', -- edit surrounding characters
|
'machakann/vim-sandwich', -- edit surrounding characters
|
||||||
'michaeljsmith/vim-indent-object', -- adds indent-level text objects
|
'michaeljsmith/vim-indent-object', -- adds indent-level text objects
|
||||||
'wellle/targets.vim', -- add many other text objects
|
-- 'wellle/targets.vim', -- add many other text objects
|
||||||
'bkad/CamelCaseMotion', -- invaluable motions for properly operating on various casings
|
'bkad/CamelCaseMotion', -- invaluable motions for properly operating on various casings
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -70,6 +70,7 @@ packer.startup(function()
|
||||||
'hrsh7th/cmp-buffer', -- add buffer information to completion engine
|
'hrsh7th/cmp-buffer', -- add buffer information to completion engine
|
||||||
'hrsh7th/cmp-path', -- add filesystem information to complete enging
|
'hrsh7th/cmp-path', -- add filesystem information to complete enging
|
||||||
'hrsh7th/cmp-cmdline', -- add completion for vim commands
|
'hrsh7th/cmp-cmdline', -- add completion for vim commands
|
||||||
|
'onsails/lspkind-nvim',
|
||||||
'saadparwaiz1/cmp_luasnip',
|
'saadparwaiz1/cmp_luasnip',
|
||||||
{
|
{
|
||||||
-- completion engine
|
-- completion engine
|
||||||
|
@ -78,6 +79,28 @@ packer.startup(function()
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
|
||||||
|
local prev_item = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local next_item = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
|
@ -88,36 +111,16 @@ packer.startup(function()
|
||||||
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||||
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
['<C-y>'] = cmp.config.disable,
|
||||||
['<C-e>'] = cmp.mapping {
|
['<C-e>'] = cmp.mapping {
|
||||||
i = cmp.mapping.abort(),
|
i = cmp.mapping.abort(),
|
||||||
c = cmp.mapping.close(),
|
c = cmp.mapping.close(),
|
||||||
},
|
},
|
||||||
['<Tab>'] = cmp.config.disable,
|
['<CR>'] = cmp.mapping.confirm { select = false },
|
||||||
['<S-Tab>'] = cmp.config.disable,
|
["<Tab>"] = cmp.mapping(next_item, { "i", "s" }),
|
||||||
['<CR>'] = cmp.mapping.confirm{select = true}, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
["<S-Tab>"] = cmp.mapping(prev_item, { "i", "s" }),
|
||||||
--[[ ["<Tab>"] = cmp.mapping(function(fallback)
|
['<C-n>'] = cmp.mapping(next_item, { "i", "s" }),
|
||||||
|
['<C-p>'] = cmp.mapping(prev_item, { "i", "s" }),
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
]]--
|
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
@ -128,9 +131,18 @@ packer.startup(function()
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
{ name = 'fuzzy_path' },
|
{ name = 'fuzzy_path' },
|
||||||
}),
|
}),
|
||||||
|
formatting = {
|
||||||
|
format = require("lspkind").cmp_format {
|
||||||
|
with_text = true,
|
||||||
|
menu = {
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp.setup.cmdline('/', {
|
cmp.setup.cmdline('/', {
|
||||||
|
-- mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
{ name = 'fuzzy_path' },
|
{ name = 'fuzzy_path' },
|
||||||
|
@ -138,6 +150,7 @@ packer.startup(function()
|
||||||
})
|
})
|
||||||
|
|
||||||
cmp.setup.cmdline(':', {
|
cmp.setup.cmdline(':', {
|
||||||
|
-- mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'path' }
|
{ name = 'path' }
|
||||||
}, {
|
}, {
|
||||||
|
@ -155,7 +168,7 @@ packer.startup(function()
|
||||||
run = ':TSUpdate',
|
run = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
require 'nvim-treesitter.configs'.setup {
|
require 'nvim-treesitter.configs'.setup {
|
||||||
ensure_installed = "maintained",
|
ensure_installed = "all",
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
ignore_install = {},
|
ignore_install = {},
|
||||||
indent = {
|
indent = {
|
||||||
|
|
|
@ -30,7 +30,7 @@ set -g monitor-activity on
|
||||||
set -g visual-bell on
|
set -g visual-bell on
|
||||||
set -g bell-action other
|
set -g bell-action other
|
||||||
set -g mode-keys vi
|
set -g mode-keys vi
|
||||||
set -g history-limit 102400000
|
set -g history-limit 1024000
|
||||||
set -g status on
|
set -g status on
|
||||||
set -g status-position bottom
|
set -g status-position bottom
|
||||||
set -g status-bg colour0
|
set -g status-bg colour0
|
||||||
|
|
Reference in a new issue