dotfiles/.config/nvim/lua/plugins/lsp.lua

317 lines
12 KiB
Lua
Raw Permalink Normal View History

2024-06-01 03:53:39 +01:00
return {
-- Rename variable pop up
{
"stevearc/dressing.nvim",
event = "VeryLazy",
opts = {
input = {
override = function(conf)
conf.col = -1
conf.row = 0
return conf
end,
}
}
},
{
"smjonas/inc-rename.nvim",
opts = {
2024-09-23 05:03:13 +01:00
save_in_cmdline_history = false,
}
2024-06-01 03:53:39 +01:00
},
{
"ThePrimeagen/refactoring.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
lazy = false,
config = function()
require("refactoring").setup()
end,
},
2024-06-01 03:53:39 +01:00
{
"williamboman/mason.nvim",
2024-06-01 04:02:34 +01:00
event = "VeryLazy",
2024-06-01 03:53:39 +01:00
config = function()
local mason = require("mason")
vim.api.nvim_create_augroup("_mason", { clear = true })
local options = {
PATH = "skip",
ui = {
icons = {
package_pending = "",
package_installed = "󰄳 ",
package_uninstalled = "",
},
keymaps = {
toggle_server_expand = "<CR>",
install_server = "i",
update_server = "u",
check_server_version = "c",
update_all_servers = "U",
check_outdated_servers = "C",
uninstall_server = "X",
cancel_installation = "<C-c>",
},
},
max_concurrent_installers = 10,
}
mason.setup(options)
end,
},
{
"williamboman/mason-lspconfig.nvim",
2024-06-01 04:02:34 +01:00
event = "VeryLazy",
2024-06-01 03:53:39 +01:00
dependencies = {
"williamboman/mason.nvim"
},
config = function()
local mason_lspconfig = require("mason-lspconfig")
local lspconfig = require("lspconfig")
mason_lspconfig.setup({
automatic_installation = false,
})
local lsp_defaults = lspconfig.util.default_config
local capabilities =
vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities())
mason_lspconfig.setup_handlers({
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["gopls"] = function()
lspconfig["gopls"].setup({
capabilities = capabilities,
settings = {
gopls = {
["ui.completion.usePlaceholders"] = true,
["ui.diagnostic.staticcheck"] = true,
["ui.inlayhint.hints"] = {
assignVariablesTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true
},
}
}
})
end,
["lua_ls"] = function()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
hint = { enable = true }
},
},
})
end,
["ltex"] = function()
lspconfig["ltex"].setup({
capabilities = capabilities,
--Local on attach
on_attach = function(_, _)
-- rest of your on_attach process.
require("ltex_extra").setup()
end,
settings = {
ltex = {
2024-07-31 14:23:19 +01:00
language = "en-GB",
},
additionalRules = {
enablePickyRules = true,
2024-06-01 03:53:39 +01:00
},
},
})
end,
["basedpyright"] = function()
lspconfig["basedpyright"].setup({
capabilities = capabilities,
settings = {
verboseOutput = true,
autoImportCompletion = true,
basedpyright = {
analysis = {
typeCheckingMode = "all",
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "openFilesOnly",
indexing = true,
},
},
},
})
end,
})
end
},
{
"neovim/nvim-lspconfig",
event = { "BufReadPost", "BufNewFile" },
dependencies = {
"williamboman/mason-lspconfig.nvim"
},
config = function()
local lspconfig = require("lspconfig")
2024-09-23 05:03:13 +01:00
2024-06-01 03:53:39 +01:00
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
local fzflua = require("fzf-lua")
local conform = require("conform")
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client ~= nil then
client.server_capabilities.semanticTokensProvider = nil
end
local rename_func = function()
return ":IncRename " .. vim.fn.expand("<cword>")
end
2024-06-01 03:53:39 +01:00
-- Mappings.
local bufopts = { noremap = true, silent = true, buffer = ev.buf }
2024-09-23 05:03:13 +01:00
local bufopts_expr = { expr = true }
2024-06-01 03:53:39 +01:00
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, bufopts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, bufopts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "gr", fzflua.lsp_references, bufopts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set("n", "gi", fzflua.lsp_implementations, bufopts)
vim.keymap.set("n", "<space>k", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
2024-09-23 05:03:13 +01:00
vim.keymap.set("n", "<space>rn", rename_func, bufopts_expr)
vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, bufopts)
2024-06-01 03:53:39 +01:00
vim.keymap.set("n", "<space>ge", vim.diagnostic.goto_next, bufopts)
vim.keymap.set("n", "<space>gE", vim.diagnostic.goto_prev, bufopts)
vim.keymap.set("n", "<space>fo", function() conform.format({ lsp_fallback = true }) end, bufopts)
end,
})
-- ADD NVIM CMP AS A CAPABILITY
local lsp_defaults = lspconfig.util.default_config
local capabilities =
vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities())
lspconfig["hls"].setup({
capabilities = capabilities,
filetypes = { 'haskell', 'lhaskell', 'cabal' },
})
end,
},
2024-07-31 14:23:19 +01:00
{
'mrcjkb/rustaceanvim',
version = '^5',
lazy = false
2024-07-31 14:23:19 +01:00
},
2024-10-11 15:12:53 +01:00
{
'akinsho/flutter-tools.nvim',
lazy = false,
dependencies = {
'nvim-lua/plenary.nvim',
'stevearc/dressing.nvim', -- optional for vim.ui.select
},
config = true,
},
2024-10-11 15:13:34 +01:00
{
"rcarriga/nvim-dap-ui",
event = "VeryLazy",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
config = function()
local dap = require("dap")
local dapui = require("dapui")
dapui.setup()
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
end
},
{
"jay-babu/mason-nvim-dap.nvim",
event = "VeryLazy",
dependencies = {
"williamboman/mason.nvim",
"mfussenegger/nvim-dap",
},
opts = {
handlers = {}
},
},
{
"mfussenegger/nvim-dap",
},
2024-06-01 03:53:39 +01:00
{
"stevearc/conform.nvim",
event = "VeryLazy",
config = function()
require("conform").setup({
formatters_by_ft = {
python = { "black" },
haskell = { "fourmolu" },
javascript = { "prettierd" },
markdown = { "mdformat" },
2024-07-31 14:23:19 +01:00
rust = { "rustfmt" },
2024-06-01 03:53:39 +01:00
go = { "gofmt" },
json = { "jq" }
}
})
end,
},
{
"lervag/vimtex",
2024-10-11 15:13:34 +01:00
filetypes = { "tex" },
2024-06-01 03:53:39 +01:00
config = function()
2024-10-07 20:16:38 +01:00
if vim.loop.os_uname().sysname == "Darwin" then
vim.g.vimtex_view_method = 'skim'
vim.g.vimtex_view_skim_sync = 1
vim.g.vimtex_view_skim_activate = 1
2024-10-07 20:16:38 +01:00
else
vim.g.vimtex_view_method = 'zathura'
end
vim.g.vimtex_compiler_method = 'latexmk'
vim.g.vimtex_view_automatic = 0
-- vim.g.vimtex_compiler_generic = { command =
-- 'ls *.tex | entr -n -c tectonic /_ --synctex --keep-intermediates --reruns 0' }
2024-06-01 03:53:39 +01:00
end,
},
{
"barreiroleo/ltex-extra.nvim",
event = "VeryLazy",
},
}