Working on lsp

This commit is contained in:
RingOfStorms (Joshua Bell) 2023-06-12 00:13:14 -05:00
parent cec6b5ba89
commit 42a3ec0172
11 changed files with 127 additions and 25 deletions

View file

@ -3,32 +3,39 @@ return {
branch = 'v2.x',
dependencies = {
-- LSP Support
{'neovim/nvim-lspconfig'},
{ 'neovim/nvim-lspconfig' },
{
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{'williamboman/mason-lspconfig.nvim'},
{ 'williamboman/mason-lspconfig.nvim' },
-- Autocompletion
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'hrsh7th/cmp-cmdline'},
{ 'hrsh7th/nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'hrsh7th/cmp-buffer' },
{ 'hrsh7th/cmp-path' },
{ 'hrsh7th/cmp-cmdline' },
-- Snips
{'L3MON4D3/LuaSnip'},
{ 'L3MON4D3/LuaSnip' },
},
config = function()
local lsp = require('lsp-zero').preset({})
local config = require 'lspconfig'
local util = require 'lspconfig/util'
local cmp = require 'cmp'
local cmp_action = require('lsp-zero').cmp_action()
lsp.on_attach(function(_, bufnr)
local capabilities = require('cmp_nvim_lsp').default_capabilities()
capabilities = vim.tbl_deep_extend("keep", capabilities, vim.lsp.protocol.make_client_capabilities());
capabilities.textDocument.completion.completionItem.snippetSupport = true
local on_attach = function(_, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
end
lsp.on_attach(on_attach)
lsp.ensure_installed({
-- -- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
"lua_ls",
@ -38,31 +45,44 @@ return {
"cssls",
"cssmodules_ls",
"pyright",
"prettierd",
"html",
"emmet_ls",
"sqlls",
"dockerls",
"docker_compose_language_service",
})
config.lua_ls.setup(lsp.nvim_lua_ls())
config.rust_analyzer.setup {}
config.tsserver.setup {}
config.tsserver.setup {
on_attach = on_attach,
capabilities = capabilities,
root_dir = nvim_lsp.util.root_pattern("tsconfig.json", ".git"),
}
config.eslint.setup {}
config.cssls.setup {}
config.cssmodules_ls.setup {}
config.pyright.setup {}
local cmp = require 'cmp'
local cmp_action = require('lsp-zero').cmp_action()
lsp.setup()
cmp.setup({
window = {
documentation = cmp.config.window.bordered(),
},
sources = {
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "buffer", keyword_length = 3 },
{ name = "luasnip", keyword_length= 2 },
{ name = "nvim_lsp", priority = 1000 },
{ name = "luasnip", priority = 750, keyword_length = 2 },
{ name = "buffer", priority = 500, keyword_length = 3 },
{ name = "path", priority = 250 },
},
mapping = {
['<CR>'] = cmp.mapping.confirm({select = false}),
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<Tab>'] = cmp_action.tab_complete(),
['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
-- Ctrl+Space to trigger completion menu
@ -72,7 +92,6 @@ return {
['<C-b>'] = cmp_action.luasnip_jump_backward(),
}
})
lsp.setup()
end,
-- keys = {
-- { "<leader>l", "<Nop>", desc = "LSP" },