LSP nvim stuff

This commit is contained in:
Daniel Flanagan 2022-04-15 12:52:46 -05:00
parent 82bceebbfd
commit 1d7acb6a57
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
4 changed files with 114 additions and 99 deletions

View file

@ -64,13 +64,8 @@ local keymap = {
['ib'] = { '<Plug>CamelCaseMotion_ib', m.s },
['ie'] = { '<Plug>CamelCaseMotion_ie', m.s },
},
c = {
['<c-n>'] = '<down>',
['<c-p>'] = '<up>',
},
i = {
['<c-q>'] = '<esc><c-q>',
['<c-n>'] = {'<Plug>(completion_trigger)', m.s},
},
}
for mode, mappings in pairs(keymap) do

View file

@ -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>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', '<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
local capabilities = require 'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities())
local common_config = {
capabilities = require'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()),
capabilities = capabilities,
on_attach = on_attach,
flags = {
debounce_text_changes = 150
@ -46,6 +47,12 @@ local lsp_configs = {
gopls = {},
elixirls = {
cmd = { vim.fn.expand '~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' },
settings = {
elixirLS = {
dialyzerEnabled = true,
fetchDeps = false,
}
}
},
sumneko_lua = {
settings = {

View file

@ -22,7 +22,7 @@ packer.startup(function()
'christoomey/vim-tmux-navigator', -- navigate vim splits and tmux panes fluidly
'machakann/vim-sandwich', -- edit surrounding characters
'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
{
@ -70,6 +70,7 @@ packer.startup(function()
'hrsh7th/cmp-buffer', -- add buffer information to completion engine
'hrsh7th/cmp-path', -- add filesystem information to complete enging
'hrsh7th/cmp-cmdline', -- add completion for vim commands
'onsails/lspkind-nvim',
'saadparwaiz1/cmp_luasnip',
{
-- completion engine
@ -78,6 +79,28 @@ packer.startup(function()
local cmp = require 'cmp'
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 {
snippet = {
expand = function(args)
@ -88,36 +111,16 @@ packer.startup(function()
['<C-b>'] = 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-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 {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
['<Tab>'] = cmp.config.disable,
['<S-Tab>'] = cmp.config.disable,
['<CR>'] = cmp.mapping.confirm{select = true}, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
--[[ ["<Tab>"] = cmp.mapping(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, { "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" }),
]]--
['<CR>'] = cmp.mapping.confirm { select = false },
["<Tab>"] = cmp.mapping(next_item, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(prev_item, { "i", "s" }),
['<C-n>'] = cmp.mapping(next_item, { "i", "s" }),
['<C-p>'] = cmp.mapping(prev_item, { "i", "s" }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
@ -128,9 +131,18 @@ packer.startup(function()
{ name = 'path' },
{ name = 'fuzzy_path' },
}),
formatting = {
format = require("lspkind").cmp_format {
with_text = true,
menu = {
nvim_lsp = "[LSP]",
},
}
},
}
cmp.setup.cmdline('/', {
-- mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' },
{ name = 'fuzzy_path' },
@ -138,6 +150,7 @@ packer.startup(function()
})
cmp.setup.cmdline(':', {
-- mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
@ -155,7 +168,7 @@ packer.startup(function()
run = ':TSUpdate',
config = function()
require 'nvim-treesitter.configs'.setup {
ensure_installed = "maintained",
ensure_installed = "all",
sync_install = false,
ignore_install = {},
indent = {

View file

@ -30,7 +30,7 @@ set -g monitor-activity on
set -g visual-bell on
set -g bell-action other
set -g mode-keys vi
set -g history-limit 102400000
set -g history-limit 1024000
set -g status on
set -g status-position bottom
set -g status-bg colour0