This commit is contained in:
abs3nt 2023-03-05 22:40:41 -08:00
parent 2c1bcc6476
commit 7820550f0c
3 changed files with 65 additions and 4 deletions

View File

@ -54,6 +54,9 @@ require('mason-lspconfig').setup_handlers {
capabilities = capabilities,
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
diagnostics = {
globals = { 'vim' }
}
@ -66,8 +69,17 @@ require('mason-lspconfig').setup_handlers {
capabilities = capabilities,
settings = {
gopls = {
gofumpt = true
experimentalPostfixCompletions = true,
gofumpt = true,
analyses = {
unusedparams = true,
shadow = true,
},
staticcheck = true,
}
},
init_options = {
usePlaceHolders = true,
}
}
end

View File

@ -5,7 +5,7 @@ vim.o.termguicolors = true
vim.o.cmdheight = 1
-- You will have bad experience for diagnostic messages when it's default 4000.
vim.o.updatetime = 300
vim.o.updatetime = 100
vim.o.mmp = 5000
-- don't give |ins-completion-menu| messages.

View File

@ -44,6 +44,10 @@ return {
vim.g.go_highlight_fields = 1
vim.g.go_highlight_functions = 1
vim.g.go_highlight_function_calls = 1
vim.g.go_highlight_operators = 1
vim.g.go_highlight_extra_types = 1
vim.g.go_highlight_build_constraints = 1
vim.g.go_auto_type_info = 1
vim.g.go_metalinter_command = 'golangci-lint'
end
},
@ -206,16 +210,36 @@ return {
{ "L3MON4D3/LuaSnip" },
{ "saadparwaiz1/cmp_luasnip" },
{ "rafamadriz/friendly-snippets" },
{ "onsails/lspkind.nvim" },
},
config = function()
require('luasnip.loaders.from_vscode').lazy_load()
local lspkind = require('lspkind')
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local cmp = require 'cmp'
local luasnip = require("luasnip")
cmp.setup({
experimental = {
ghost_text = true
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
format = lspkind.cmp_format({
mode = 'symbol',
maxwidth = 50,
ellipsis_char = '...',
before = function(entry, vim_item)
return vim_item
end
})
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
@ -226,6 +250,28 @@ return {
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = false }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
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({
{ name = 'nvim_lsp' },
@ -233,6 +279,8 @@ return {
{ name = 'path' },
{ name = 'luasnip' },
{ name = 'neorg' },
}, {
{ name = 'buffer' },
})
})
@ -259,6 +307,7 @@ return {
{ name = 'cmdline' }
})
})
require('luasnip.loaders.from_vscode').lazy_load()
end,
},