Cleanup LSP config, auto open trouble for diagnostics

This commit is contained in:
Evie Litherland-Smith 2023-02-15 15:26:03 +00:00
parent d32cc47954
commit ccb49c3cd0
2 changed files with 29 additions and 29 deletions

View file

@ -25,7 +25,7 @@ end
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local on_attach = function(_, bufnr)
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
@ -53,41 +53,22 @@ local lsp_flags = {
debounce_text_changes = 150,
}
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Set up null_ls first
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.diagnostics.mypy,
null_ls.builtins.diagnostics.zsh,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.trim_whitespace,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.prettier,
null_ls.builtins.hover.dictionary,
},
lspconfig.pyright.setup({
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
})
require("lspconfig")["pyright"].setup({
lspconfig.fortls.setup({
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
})
require("lspconfig")["fortls"].setup({
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
})
require("lspconfig")["lua_ls"].setup({
lspconfig.lua_ls.setup({
settings = {
Lua = {
runtime = {
@ -110,7 +91,26 @@ require("lspconfig")["lua_ls"].setup({
capabilities = capabilities,
})
require("lspconfig")["texlab"].setup({
lspconfig.texlab.setup({
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
})
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.diagnostics.mypy,
null_ls.builtins.diagnostics.zsh,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.trim_whitespace,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.prettier,
null_ls.builtins.hover.dictionary,
},
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,

View file

@ -3,7 +3,7 @@ require("trouble").setup({
height = 10, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
fold_open = "", -- icon used for open folds
fold_closed = "", -- icon used for closed folds
group = true, -- group results by file
@ -30,11 +30,11 @@ require("trouble").setup({
next = "j", -- next item
},
indent_lines = true, -- add an indent guide below the fold icons
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = true, -- automatically close the list when you have no diagnostics
auto_open = true, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
auto_jump = { "lsp_definitions", "lsp_references", "lsp_implementations" }, -- for the given modes, automatically jump if there is only a single result
signs = {
-- icons / text used for a diagnostic
error = "",