Compare commits

...

6 Commits

4 changed files with 141 additions and 139 deletions

View File

@ -1,40 +1,42 @@
local M = {}
local on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = true
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
client.server_capabilities.documentFormattingProvider = true
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
end
M.on_attach = on_attach;
M.on_attach = on_attach
M.settings = {
codeAction = {
disableRuleComment = {
enable = true,
location = "separateLine"
},
showDocumentation = {
enable = true
}
},
codeActionOnSave = {
enable = false,
mode = "all"
},
format = true,
nodePath = "",
onIgnoredFiles = "off",
packageManager = "npm",
quiet = false,
rulesCustomizations = {},
run = "onType",
useESLintClass = false,
validate = "on",
workingDirectory = {
mode = "location"
}
codeAction = {
disableRuleComment = {
enable = true,
location = "separateLine",
},
showDocumentation = {
enable = true,
},
},
codeActionOnSave = {
enable = false,
mode = "all",
},
format = true,
nodePath = "",
onIgnoredFiles = "off",
packageManager = "npm",
quiet = false,
rulesCustomizations = {},
run = "onType",
useESLintClass = false,
validate = "on",
workingDirectory = {
mode = "location",
},
}
return M

View File

@ -15,49 +15,3 @@ map("n", "<leader>+", ":bNext<cr>") --switch tabs
map("n", "<leader>n", ":Neotree toggle<cr>") --open Nerdtree
map("n", "<leader>z", ":ZenMode<cr>") --open ZenMode (distraction-free)
map("n", "<leader>d", ":ToggleDiag<cr>") -- toggle all diagnostics
vim.api.nvim_create_autocmd("LspAttach", {
desc = "LSP actions",
callback = function()
local bufmap = function(mode, lhs, rhs)
local opts = { buffer = true }
vim.keymap.set(mode, lhs, rhs, opts)
end
-- Displays hover information about the symbol under the cursor
bufmap("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>")
-- Jump to the definition
bufmap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>")
-- Jump to declaration
bufmap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>")
-- Lists all the implementations for the symbol under the cursor
bufmap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<cr>")
-- Jumps to the definition of the type symbol
bufmap("n", "go", "<cmd>lua vim.lsp.buf.type_definition()<cr>")
-- Lists all the references
bufmap("n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>")
-- Displays a function's signature information
bufmap("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>")
-- Renames all references to the symbol under the cursor
bufmap("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>")
-- Selects a code action available at the current cursor position
bufmap("n", "<F4>", "<cmd>lua vim.lsp.buf.code_action()<cr>")
-- Show diagnostics in a floating window
bufmap("n", "gl", "<cmd>lua vim.diagnostic.open_float()<cr>")
-- Move to the previous diagnostic
bufmap("n", "nd", "<cmd>lua vim.diagnostic.goto_prev()<cr>")
-- Move to the next diagnostic
bufmap("n", "nd", "<cmd>lua vim.diagnostic.goto_next()<cr>")
end,
})

View File

@ -1,51 +1,51 @@
return {
{
"mfussenegger/nvim-lint",
event = {
"BufReadPre",
"BufNewFile",
},
config = function()
require("mason-tool-installer").setup({
ensure_installed = {
"prettier", -- prettier formatter
-- "stylua", -- lua formatter
"isort", -- python formatter
"black", -- python formatter
"pylint", -- python linter
"biome", -- js linter
},
})
local lint = require("lint")
lint.linters_by_ft = {
javascript = { "eslint_d" },
typescript = { "biomejs" },
javascriptreact = { "biomejs" },
typescriptreact = { "biomejs" },
svelte = { "biomejs" },
python = { "pylint" },
-- markdown = { "marksman" },
lua = { "luacheck" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting for current file" })
vim.keymap.set("n", "<leader>L", function()
vim.diagnostic.open_float()
end, { desc = "Open diagnostic in pop-up" })
end,
},
-- {
-- "mfussenegger/nvim-lint",
-- event = {
-- "BufReadPre",
-- "BufNewFile",
-- },
--
-- config = function()
-- require("mason-tool-installer").setup({
-- ensure_installed = {
-- "prettier", -- prettier formatter
-- -- "stylua", -- lua formatter
-- "isort", -- python formatter
-- "black", -- python formatter
-- "pylint", -- python linter
-- "biome", -- js linter
-- },
-- })
-- local lint = require("lint")
-- lint.linters_by_ft = {
-- --javascript = { "eslint_d" },
-- typescript = { "biomejs" },
-- javascriptreact = { "biomejs" },
-- typescriptreact = { "biomejs" },
-- svelte = { "biomejs" },
-- python = { "pylint" },
-- -- markdown = { "marksman" },
-- lua = { "luacheck" },
-- }
--
-- local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
--
-- vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
-- group = lint_augroup,
-- callback = function()
-- lint.try_lint()
-- end,
-- })
--
-- vim.keymap.set("n", "<leader>l", function()
-- lint.try_lint()
-- end, { desc = "Trigger linting for current file" })
-- vim.keymap.set("n", "<leader>L", function()
-- vim.diagnostic.open_float()
-- end, { desc = "Open diagnostic in pop-up" })
-- end,
-- },
{
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
config = function()

View File

@ -19,7 +19,7 @@ require("mason").setup({
require("mason-lspconfig").setup({
ensure_installed = {
"tsserver",
-- "tsserver",
"cssls",
"html",
"bashls",
@ -33,6 +33,54 @@ require("mason-lspconfig").setup({
},
})
local on_attach = function()
vim.api.nvim_create_autocmd("LspAttach", {
desc = "LSP actions",
callback = function()
local bufmap = function(mode, lhs, rhs)
local opts = { buffer = true }
vim.keymap.set(mode, lhs, rhs, opts)
end
-- Displays hover information about the symbol under the cursor
bufmap("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>")
-- Jump to the definition
bufmap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>")
-- Jump to declaration
bufmap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>")
-- Lists all the implementations for the symbol under the cursor
bufmap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<cr>")
-- Jumps to the definition of the type symbol
bufmap("n", "go", "<cmd>lua vim.lsp.buf.type_definition()<cr>")
-- Lists all the references
bufmap("n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>")
-- Displays a function's signature information
bufmap("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>")
-- Renames all references to the symbol under the cursor
bufmap("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>")
-- Selects a code action available at the current cursor position
bufmap("n", "<F4>", "<cmd>lua vim.lsp.buf.code_action()<cr>")
-- Show diagnostics in a floating window
bufmap("n", "gl", "<cmd>lua vim.diagnostic.open_float()<cr>")
-- Move to the previous diagnostic
bufmap("n", "nd", "<cmd>lua vim.diagnostic.goto_prev()<cr>")
-- Move to the next diagnostic
bufmap("n", "nd", "<cmd>lua vim.diagnostic.goto_next()<cr>")
end,
})
end
local lspconfig = require("lspconfig")
require("mason-lspconfig").setup_handlers({
@ -43,29 +91,27 @@ require("mason-lspconfig").setup_handlers({
require("lspconfig")[server_name].setup({
on_attach = on_attach,
capabilities = lsp_capabilities,
--handlers = handlers,
})
end,
["eslint"] = function()
lspconfig.eslint.setup({
capabilities = lsp_capabilities,
--handlers = handlers,
on_attach = require("config.lsp.servers.eslint").on_attach,
settings = require("config.lsp.servers.eslint").settings,
})
end,
-- ["eslint"] = function()
-- lspconfig.eslint.setup({
-- capabilities = lsp_capabilities,
-- on_attach = require("config.lsp.servers.eslint").on_attach,
-- settings = require("config.lsp.servers.eslint").settings,
-- })
-- end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({
capabilities = lsp_capabilities,
on_attach = require("config.lsp.servers.lua").on_attach,
on_attach = on_attach,
settings = require("config.lsp.servers.lua").settings,
})
end,
["ltex"] = function()
lspconfig.ltex.setup({
capabilities = lsp_capabilities,
settings = require("config.lsp.servers.latex").settings,
})
end
lspconfig.ltex.setup({
capabilities = lsp_capabilities,
on_attach = on_attach,
settings = require("config.lsp.servers.latex").settings,
})
end,
})