Compare commits

..

No commits in common. "3c135569268294b0d974e1ee68c6901861a75703" and "c77982315217add9f6e7250c98563f8f0acb1993" have entirely different histories.

4 changed files with 139 additions and 141 deletions

View File

@ -2,28 +2,26 @@ local M = {}
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = true client.server_capabilities.documentFormattingProvider = true
local function buf_set_option(...) local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
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 end
M.on_attach = on_attach M.on_attach = on_attach;
M.settings = { M.settings = {
codeAction = { codeAction = {
disableRuleComment = { disableRuleComment = {
enable = true, enable = true,
location = "separateLine", location = "separateLine"
}, },
showDocumentation = { showDocumentation = {
enable = true, enable = true
}, }
}, },
codeActionOnSave = { codeActionOnSave = {
enable = false, enable = false,
mode = "all", mode = "all"
}, },
format = true, format = true,
nodePath = "", nodePath = "",
@ -35,8 +33,8 @@ M.settings = {
useESLintClass = false, useESLintClass = false,
validate = "on", validate = "on",
workingDirectory = { workingDirectory = {
mode = "location", mode = "location"
}, }
} }
return M return M

View File

@ -15,3 +15,49 @@ map("n", "<leader>+", ":bNext<cr>") --switch tabs
map("n", "<leader>n", ":Neotree toggle<cr>") --open Nerdtree map("n", "<leader>n", ":Neotree toggle<cr>") --open Nerdtree
map("n", "<leader>z", ":ZenMode<cr>") --open ZenMode (distraction-free) map("n", "<leader>z", ":ZenMode<cr>") --open ZenMode (distraction-free)
map("n", "<leader>d", ":ToggleDiag<cr>") -- toggle all diagnostics 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 { return {
-- { {
-- "mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
-- event = { event = {
-- "BufReadPre", "BufReadPre",
-- "BufNewFile", "BufNewFile",
-- }, },
--
-- config = function() config = function()
-- require("mason-tool-installer").setup({ require("mason-tool-installer").setup({
-- ensure_installed = { ensure_installed = {
-- "prettier", -- prettier formatter "prettier", -- prettier formatter
-- -- "stylua", -- lua formatter -- "stylua", -- lua formatter
-- "isort", -- python formatter "isort", -- python formatter
-- "black", -- python formatter "black", -- python formatter
-- "pylint", -- python linter "pylint", -- python linter
-- "biome", -- js linter "biome", -- js linter
-- }, },
-- }) })
-- local lint = require("lint") local lint = require("lint")
-- lint.linters_by_ft = { lint.linters_by_ft = {
-- --javascript = { "eslint_d" }, javascript = { "eslint_d" },
-- typescript = { "biomejs" }, typescript = { "biomejs" },
-- javascriptreact = { "biomejs" }, javascriptreact = { "biomejs" },
-- typescriptreact = { "biomejs" }, typescriptreact = { "biomejs" },
-- svelte = { "biomejs" }, svelte = { "biomejs" },
-- python = { "pylint" }, python = { "pylint" },
-- -- markdown = { "marksman" }, -- markdown = { "marksman" },
-- lua = { "luacheck" }, lua = { "luacheck" },
-- } }
--
-- local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
--
-- vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
-- group = lint_augroup, group = lint_augroup,
-- callback = function() callback = function()
-- lint.try_lint() lint.try_lint()
-- end, end,
-- }) })
--
-- vim.keymap.set("n", "<leader>l", function() vim.keymap.set("n", "<leader>l", function()
-- lint.try_lint() lint.try_lint()
-- end, { desc = "Trigger linting for current file" }) end, { desc = "Trigger linting for current file" })
-- vim.keymap.set("n", "<leader>L", function() vim.keymap.set("n", "<leader>L", function()
-- vim.diagnostic.open_float() vim.diagnostic.open_float()
-- end, { desc = "Open diagnostic in pop-up" }) end, { desc = "Open diagnostic in pop-up" })
-- end, end,
-- }, },
{ {
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim", "WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
config = function() config = function()

View File

@ -19,7 +19,7 @@ require("mason").setup({
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
ensure_installed = { ensure_installed = {
-- "tsserver", "tsserver",
"cssls", "cssls",
"html", "html",
"bashls", "bashls",
@ -33,54 +33,6 @@ 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") local lspconfig = require("lspconfig")
require("mason-lspconfig").setup_handlers({ require("mason-lspconfig").setup_handlers({
@ -91,27 +43,29 @@ require("mason-lspconfig").setup_handlers({
require("lspconfig")[server_name].setup({ require("lspconfig")[server_name].setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = lsp_capabilities, 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, 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() ["lua_ls"] = function()
lspconfig.lua_ls.setup({ lspconfig.lua_ls.setup({
capabilities = lsp_capabilities, capabilities = lsp_capabilities,
on_attach = on_attach, on_attach = require("config.lsp.servers.lua").on_attach,
settings = require("config.lsp.servers.lua").settings, settings = require("config.lsp.servers.lua").settings,
}) })
end, end,
["ltex"] = function() ["ltex"] = function()
lspconfig.ltex.setup({ lspconfig.ltex.setup({
capabilities = lsp_capabilities, capabilities = lsp_capabilities,
on_attach = on_attach,
settings = require("config.lsp.servers.latex").settings, settings = require("config.lsp.servers.latex").settings,
}) })
end, end
}) })