feat(nvim): finish configuring lsp-zero.nvim

Fixes #49
This commit is contained in:
Oliver Davies 2023-04-26 07:59:02 +01:00
parent 1bcd135786
commit 35bef73170
3 changed files with 28 additions and 102 deletions

View file

@ -1,75 +0,0 @@
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
vim.opt.shortmess:append "c"
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-e>"] = cmp.mapping.close(),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping.confirm { select = true },
["<tab>"] = cmp.config.disable,
},
sources = {
{ name = "nvim_lsp_signature_help" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "cmp_tabnine" },
{ name = "path" },
{ name = "luasnip" },
{ name = "buffer", keyword_length = 5, max_item_count = 5 },
},
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
formatting = {
format = require("lspkind").cmp_format {
with_text = true,
menu = {
buffer = "[buf]",
cmp_tabnine = "[tn]",
luasnip = "[snip]",
nvim_lsp = "[lsp]",
nvim_lua = "[lua]",
path = "[path]",
},
},
},
experimental = {
ghost_text = false,
native_menu = false,
},
}
vim.cmd [[
augroup DadbodSql
au!
autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer { sources = { { name = 'vim-dadbod-completion' } } }
augroup END
]]

View file

@ -1,11 +1,19 @@
local lsp = require 'lsp-zero'
local lspconfig = require "lspconfig"
local cmp = require('cmp')
local lsp = require('lsp-zero')
local lspconfig = require('lspconfig')
lsp.preset({
float_border = 'none',
});
lsp.preset("recommended")
lsp.nvim_workspace()
local on_attach = function(client, bufnr)
lsp.default_keymaps({buffer = bufnr})
local opts = { buffer = true }
vim.keymap.set("n", "<leader>ca", vim.lsp.code_action, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
end
lsp.on_attach(on_attach)
lsp.setup_servers({
'ansiblels',
@ -24,30 +32,11 @@ lsp.setup_servers({
'yamlls'
})
lsp.set_preferences({
sign_icons = {
error = 'E',
hint = 'H',
info = 'I',
warn = 'W',
},
suggest_lsp_servers = false,
})
lsp.on_attach(on_attach)
lsp.setup()
vim.diagnostic.config({
virtual_text = true
})
lspconfig.intelephense.setup({
filetypes = { "php", "module", "test", "inc" },
})
lspconfig.tailwindcss.setup({
on_attach = on_attach,
filetypes = {
"astro",
"html",
@ -66,5 +55,16 @@ lspconfig.tailwindcss.setup({
},
})
vim.diagnostic.config({
virtual_text = false,
})
cmp.setup({
preselect = 'item',
completion = {
completeopt = 'menu,menuone,noinsert'
},
})
require "opdavies.lsp.null-ls"
require "opdavies.lsp.signature"

View file

@ -36,5 +36,6 @@ null_ls.setup {
diagnostics.phpstan,
diagnostics.shellcheck,
},
temp_dir = "/tmp",
}