Files
dotfiles/.config/nvim/lua/plugins/lsp_config.lua
T

286 lines
8.0 KiB
Lua

return {
{
"mason-org/mason.nvim",
lazy = false,
-- event = { "UIEnter" },
--cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUpdate", "MasonUninstallAll", "MasonLog" },
opts = {},
},
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
build = ":TSUpdate",
-- event = { "UIEnter" },
opts = {
sync_install = false,
auto_install = true,
highlight = {
enable = true,
-- disable for files bigger than 500KB
disable = function(lang, buf)
local max_filesize = 500 * 1024 -- 500 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then return true end
end,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
ensure_installed = {
"bash",
-- "dart",
"html",
"javascript",
"gdscript",
"lua",
"php",
"rust",
"python",
"typescript",
"vim",
},
},
},
{
"mason-org/mason-lspconfig.nvim",
lazy = false,
-- events = { "UIEnter" }
opts = {
ensure_installed = {
"rust_analyzer",
-- "ruff",
"biome",
--"quick_lint_js",
--"eslint",
"html",
"cssls",
-- "sqls",
-- "hyprls",
"lua_ls",
-- "pylyzer",
-- "vimls",
"ts_ls",
},
automatic_enable = { true, rust_analyzer = false },
},
},
{
"neovim/nvim-lspconfig",
lazy = false, -- REQUIRED: tell lazy.nvim to start this plugin at startup
dependencies = {
-- main one
{ "ms-jpq/coq_nvim", branch = "coq", lazy = false },
-- 9000+ Snippets
{ "ms-jpq/coq.artifacts", branch = "artifacts", lazy = false },
-- lua & third party sources -- See https://github.com/ms-jpq/coq.thirdparty
-- Need to **configure separately**
{ "ms-jpq/coq.thirdparty", branch = "3p", lazy = false },
-- - shell repl
-- - nvim lua api
-- - scientific calculator
-- - comment banner
-- - etc
},
opts = {
-- inlay_hint = { enabled = true },
-- lsp = {
-- inlay_hint = { enabled = true },
-- },
},
init = function()
vim.g.coq_settings = {} -- Your COQ settings here
-- vim.lsp.inlay_hints.enable()
end,
--coq.nvim: lsp_ensure_capabilities is a no-op in v2. neovim 0.12's vim.lsp.protocol.make_client_capabilities() already covers what v1 used to inject. Drop the wrapping call.
---@type vim.lsp.Config
config = function()
vim.lsp.config(
"rust_analyzer",
vim.lsp.protocol.make_client_capabilities({
settings = {
["rust-analyzer"] = {
imports = {
granularity = {
group = "module",
},
prefix = "self",
},
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true,
},
},
-- inlay_hint = { enabled = true },
},
})
)
-- vim.lsp.enable("gdscript")
-- vim.lsp.enable({ "gdscript" })
-- vim.lsp.enable({ "lua_ls" })
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.o[ev.buf].omnifunc = vim.lsp.omnifunc -- TODO: fix this
-- vim.o.omnifunc.set(vim.lsp.omnifunc)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "<leader>le", vim.diagnostic.open_float)
-- vim.keymap.set("n", "<leader>lh", vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()))
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.incoming_calls, opts)
vim.keymap.set("n", "go", vim.lsp.buf.outgoing_calls, opts)
vim.keymap.set("n", "<leader>K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
-- vim.keymap.set("n", "<leader>F", function() vim.lsp.buf.format({ async = true }) end, opts)
end,
})
end,
-- keys = {
-- {
-- "<leader>lh",
-- function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end,
-- desc = "toggle inlay hints",
-- },
-- },
},
{
"mfussenegger/nvim-lint",
event = { "BufEnter", "InsertLeave" },
lazy = true,
opts = {
linters_by_ft = {
cpp = { "cpplint" },
dart = { "flutter" },
gdscript = { "gdlint" },
gitcommit = { "commitlint" },
lua = { "ast-grep" },
markdown = {},
fish = { "fish_lsp" },
sql = { "sqruff" },
python = { "ruff" },
r = { "r-languageserver" },
javascript = { "eslint" },
typescript = { "eslint" },
},
},
config = function()
local lint = require("lint")
vim.api.nvim_create_autocmd({ "BufEnter", "InsertLeave" }, {
callback = function() lint.try_lint() end,
})
end,
},
-- supposedly faster formatter
{
"stevearc/conform.nvim",
event = { "BufWritePre" },
keys = {
{
"<leader>i",
--function() require("conform").format({ async = true }) end,
desc = "Auto format file with formatter, also on F3",
},
{
"F3",
--function() require("conform").format({ async = true }) end,
--mode = { "n", "i" },
desc = "Auto format file with formatter",
},
},
opts = {},
config = {
formatters_by_ft = {
lua = { "stylua" },
rust = { "rustfmt", lsp_format = "fallback" },
-- Conform will run multiple formatters sequentially
python = { "ruff", "autopep8", lsp_format = "fallback" },
gdscript = { "gdformat" },
bash = { "shellharden" },
javascript = { "biome" },
typescript = { "biome" },
r = { "air" }, -- how to make air use tabs not spaces
css = { "ast-grep" },
html = { "ast-grep" },
-- sql = { "sqruff" },
json = { "biome" },
yaml = { "biome" },
vue = { "biome" },
},
format_on_save = {
timeout_ms = 700,
lsp_format = "fallback",
},
log_level = vim.log.levels.WARNING,
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
pattern = "*",
callback = function(args) require("conform").format({ bufnr = args.buf }) end,
}),
function()
require("conform").formatters.prettier = {
inherit = true,
command = "prettier",
prepend_args = { "--tab-width", "4" },
}
require("conform").formatters.biome = {
command = "biome format",
prepend_args = "--indent-width=4 --use-editorconfig=true",
}
require("conform").formatters.stylua = {
prepend = "--column-width=80",
}
require("conform").formatters.gdformat = {
command = "gdformat",
prepend_args = { "--fast {%}" },
}
end,
},
},
-- { "nvim-treesitter/nvim-treesitter-textobjects", lazy = true, event = "BufRead" },
{
"nvim-treesitter/nvim-treesitter-context",
lazy = true,
branch = "master",
event = "BufRead",
opts = {
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 3, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 35, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
lazy = true,
multiline_threshold = 1, -- Maximum number of lines to show for a single context
trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = "topline", -- Line used to calculate context. Choices: 'cursor', 'topline'.
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = "—",
zindex = 20, -- The Z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
},
},
{
"nvim-flutter/flutter-tools.nvim",
lazy = false,
--event = { "BufEnter" },
--ft = "*.dart",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = true,
},
-- {
-- "jubnzv/virtual-types.nvim",
-- lazy = false,
-- },
}