working lsp and documentation
This commit is contained in:
+30
-14
@@ -1,15 +1,29 @@
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
virtual_text = true, -- Text to the right of issues
|
||||
signs = false,
|
||||
underline = true,
|
||||
})
|
||||
|
||||
-- Filetype by extension
|
||||
vim.filetype.add {
|
||||
extension = {
|
||||
jinja = 'jinja',
|
||||
jinja2 = 'jinja',
|
||||
j2 = 'jinja',
|
||||
py = 'python'
|
||||
},
|
||||
}
|
||||
|
||||
-- Languageserver config overrides
|
||||
-- To enable a server a config must be present here
|
||||
-- Default Configs are provided by nvim_lspconfig
|
||||
local servers = {
|
||||
-- <server_name> = { <config> },
|
||||
ts_ls = {},
|
||||
eslint = {},
|
||||
lua_ls = {
|
||||
cmd = { "lua-language-server" },
|
||||
filetypes = { "lua" }
|
||||
lua_ls = {},
|
||||
jinja_lsp = {
|
||||
filetypes = { 'jinja', 'rust', 'python' },
|
||||
},
|
||||
rust_analyzer = {},
|
||||
ast_grep = {},
|
||||
@@ -23,32 +37,33 @@ for server, config in pairs(servers) do
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
|
||||
local builtin = require('telescope.builtin');
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local opts = { buffer = args.buf }
|
||||
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) -- Show type and defintion data (C-w C-w to enter it like any other buffer)
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- Show a detailed error description (can be run on lines with any error)
|
||||
vim.keymap.set("n", "gd", builtin.lsp_definitions, opts) -- Go to definition
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- Rename symbol under cursor project wide through ls
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts) -- Execute a ls code action
|
||||
|
||||
-- vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = 1, float = true }) end, opts)
|
||||
-- vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = -1, float = true }) end, opts)
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
|
||||
end
|
||||
})
|
||||
|
||||
-- Does code completion
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<CR>"] = cmp.mapping.confirm(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(), -- Scroll down
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(), -- Scroll Up
|
||||
["<CR>"] = cmp.mapping.confirm(), -- Confirm currently suggested code completion
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
@@ -56,6 +71,7 @@ cmp.setup({
|
||||
}
|
||||
})
|
||||
|
||||
-- Mason is only used for managing Languageserver binaries. Run :MasonInstallAll on first install
|
||||
require("mason").setup()
|
||||
|
||||
local ensure_installed = {
|
||||
|
||||
Reference in New Issue
Block a user