commit 8ca98bf78311b469c835d8112d6e589076b62830
parent a10499f8a7a4abe1c0d079b5b4bd4fe1470815d9
Author: Milutin Popovic <milutin@popovic.xyz>
Date: Fri, 10 Apr 2026 23:56:02 +0100
update to newest standards
Diffstat:
3 files changed, 182 insertions(+), 210 deletions(-)
diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua
@@ -1,5 +1,7 @@
+---@diagnostic disable: undefined-global
return {
"hrsh7th/nvim-cmp",
+ event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
@@ -7,99 +9,105 @@ return {
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
- "zbirenbaum/copilot-cmp"
+ "zbirenbaum/copilot-cmp",
},
- config = function ()
- vim.o.winborder = 'single'
- require("copilot_cmp").setup()
- local cmp = require('cmp')
+ config = function()
+ vim.o.winborder = "single"
+
+ local map = vim.keymap.set
+
+ local ok_copilot_cmp, copilot_cmp = pcall(require, "copilot_cmp")
+ if ok_copilot_cmp then
+ copilot_cmp.setup()
+ end
+
+ local cmp = require("cmp")
+ local luasnip = require("luasnip")
+
cmp.setup({
snippet = {
expand = function(args)
- vim.snippet.expand(args.body)
+ luasnip.lsp_expand(args.body)
end,
},
- mapping = {
- ["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
- ["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
- ['<`-j>'] = cmp.mapping.scroll_docs(-4),
- ['<`-k>'] = cmp.mapping.scroll_docs(4),
- ['<C-a>'] = cmp.mapping(
- cmp.mapping.confirm {
- behavior = cmp.ConfirmBehavior.Insert,
- select = true,
- },
- { "i", "c" }
- ),
- },
- sources = {
- { name = 'copilot' },
- { name = 'nvim_lsp'},
- { name = 'luasnip' },
- { name = 'buffer' },
- { name = 'path' },
- },
+
+ mapping = cmp.mapping.preset.insert({
+ ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<`-j>"] = cmp.mapping.scroll_docs(-4),
+ ["<`-k>"] = cmp.mapping.scroll_docs(4),
+ ["<C-a>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
+ }),
+
+ sources = cmp.config.sources({
+ { name = "copilot" },
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ }, {
+ { name = "buffer" },
+ { name = "path" },
+ }),
+
window = {
- documentation = {
- winhighlight = 'Normal:CmpPmenu,CursorLine:PmenuSel,Search:None,NormalFloat:Normal',
- },
- completion = {
- winhighlight = 'Normal:CmpPmenu,CursorLine:PmenuSel,Search:None,NormalFloat:Normal',
- },
+ completion = cmp.config.window.bordered({
+ winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None,NormalFloat:Normal",
+ }),
+ documentation = cmp.config.window.bordered({
+ winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None,NormalFloat:Normal",
+ }),
},
+
formatting = {
- fields = {'menu', 'abbr', 'kind'},
+ fields = { "abbr", "kind", "menu" },
format = function(entry, item)
- local menu_icon ={
- nvim_lsp = 'λ',
- luasnip = '⋗',
- buffer = 'Ω',
- path = '🖫',
- copilot = " "
+ local menu_icon = {
+ nvim_lsp = "λ",
+ luasnip = "⋗",
+ buffer = "Ω",
+ path = "🖫",
+ copilot = " ",
}
- item.menu = menu_icon[entry.source.name]
+ item.menu = menu_icon[entry.source.name] or ""
return item
end,
},
})
- local endhints = require("lsp-endhints")
- endhints.enable()
- endhints.setup {
- icons = {
- type = "-> ",
- parameter = "<= ",
- offspec = "<= ", -- hint kind not defined in official LSP spec
- unknown = "? ", -- hint kind is nil
- },
- label = {
- truncateAtChars = 50,
- padding = 1,
- marginLeft = 0,
- sameKindSeparator = ", ",
- },
- extmark = {
- priority = 50,
- },
- autoEnableHints = true,
- }
+ local ok_endhints, endhints = pcall(require, "lsp-endhints")
+ if ok_endhints then
+ endhints.setup({
+ icons = {
+ type = "-> ",
+ parameter = "<= ",
+ offspec = "<= ",
+ unknown = "? ",
+ },
+ label = {
+ truncateAtChars = 50,
+ padding = 1,
+ marginLeft = 0,
+ sameKindSeparator = ", ",
+ },
+ extmark = {
+ priority = 50,
+ },
+ autoEnableHints = true,
+ })
+ endhints.enable()
+ end
- map('n', '<leader>h', function(bufnr)
- if vim.lsp.inlay_hint.is_enabled() then
- print("Inlay Hitnts OFF")
- else
- print("Inlay Hitnts ON")
- end
- vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled(), bufnr)
- end, { silent = true, noremap = true })
+ map("n", "<leader>h", function()
+ local bufnr = vim.api.nvim_get_current_buf()
+ local enabled = vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr })
+ vim.lsp.inlay_hint.enable(not enabled, { bufnr = bufnr })
+ vim.notify("Inlay hints " .. (enabled and "OFF" or "ON"))
+ end, { silent = true, desc = "Toggle inlay hints" })
- map('n', '<leader>d', function()
- if vim.diagnostic.is_enabled() then
- print("Diagnostics OFF")
- else
- print("Diagnostics ON")
- end
- vim.diagnostic.enable(not vim.diagnostic.is_enabled())
- end, { silent = true, noremap = true })
- end
+ map("n", "<leader>d", function()
+ local bufnr = vim.api.nvim_get_current_buf()
+ local enabled = vim.diagnostic.is_enabled({ bufnr = bufnr })
+ vim.diagnostic.enable(not enabled, { bufnr = bufnr })
+ vim.notify("Diagnostics " .. (enabled and "OFF" or "ON"))
+ end, { silent = true, desc = "Toggle diagnostics" })
+ end,
}
diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua
@@ -9,11 +9,16 @@ return {
"hrsh7th/cmp-nvim-lsp",
},
config = function()
- map = vim.keymap.set
- vim.opt.signcolumn = "yes"
- vim.lsp.inlay_hint.enable(true)
+ local map = vim.keymap.set
+
+ local capabilities = vim.lsp.protocol.make_client_capabilities()
+ capabilities = vim.tbl_deep_extend(
+ "force",
+ capabilities,
+ require("cmp_nvim_lsp").default_capabilities()
+ )
+ require("lspconfig").util.default_config.capabilities = capabilities
- local lspconfig_defaults = require("lspconfig").util.default_config
require("conform").setup({
formatters_by_ft = {
javascript = { "prettier" },
@@ -23,6 +28,7 @@ return {
vue = { "prettier" },
css = { "prettier" },
scss = { "prettier" },
+ lua = { "prettier" },
less = { "prettier" },
html = { "prettier" },
json = { "prettier" },
@@ -40,50 +46,68 @@ return {
},
})
- local cmp = require("cmp")
- local cmp_lsp = require("cmp_nvim_lsp")
- local capabilities =
- vim.tbl_deep_extend("force", lspconfig_defaults.capabilities, cmp_lsp.default_capabilities())
- lspconfig_defaults.capabilities = capabilities
-
vim.api.nvim_create_autocmd("LspAttach", {
desc = "LSP actions",
callback = function(event)
- local opts = { buffer = event.buf }
+ local bufnr = event.buf
+ local opts = { buffer = bufnr }
+
+ local client = vim.lsp.get_client_by_id(event.data.client_id)
+ if client and client.server_capabilities.inlayHintProvider then
+ vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
+ end
+
+ map("n", "K", vim.lsp.buf.hover, opts)
+ map("n", "gd", vim.lsp.buf.definition, opts)
+ map("n", "gD", vim.lsp.buf.declaration, opts)
+ map("n", "gi", vim.lsp.buf.implementation, opts)
+ map("n", "go", vim.lsp.buf.type_definition, opts)
+ map("n", "gr", vim.lsp.buf.references, opts)
+ map("n", "gs", vim.lsp.buf.signature_help, opts)
- map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", opts)
- map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", opts)
- map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", opts)
- map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<cr>", opts)
- map("n", "go", "<cmd>lua vim.lsp.buf.type_definition()<cr>", opts)
- map("n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>", opts)
- map("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts)
map("n", "gq", function()
require("conform").format({ async = true, lsp_fallback = true })
end, opts)
- map("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
- map({ "n", "x" }, "<F3>", "<cmd>lua vim.lsp.buf.format({async = true})<cr>", opts)
- map("n", "<F4>", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
+
+ map("n", "<F2>", vim.lsp.buf.rename, opts)
+ map({ "n", "x" }, "<F3>", function()
+ vim.lsp.buf.format({ async = true })
+ end, opts)
+ map("n", "<F4>", vim.lsp.buf.code_action, opts)
end,
})
require("fidget").setup({})
+ local lspconfig = require("lspconfig")
+
+ lspconfig.lua_ls.setup({
+ settings = {
+ Lua = {
+ runtime = { version = "LuaJIT" },
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ checkThirdParty = false,
+ },
+ telemetry = { enable = false },
+ },
+ },
+ })
+
require("mason").setup()
require("mason-lspconfig").setup({
handlers = {
-
function(server_name)
if server_name == "rust_analyzer" then
return
end
-
- require("lspconfig")[server_name].setup({
- capabilities = capabilities,
- })
+ lspconfig[server_name].setup({})
end,
+
["eslint"] = function()
- local lspconfig = require("lspconfig")
lspconfig.eslint.setup({
cmd = { "vscode-eslint-language-server", "--stdio" },
filetypes = {
@@ -98,55 +122,32 @@ return {
"astro",
"htmlangular",
},
- on_attach = function(client, bufnr)
- vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()")
+ on_attach = function(_, bufnr)
+ vim.bo[bufnr].formatexpr = "v:lua.vim.lsp.formatexpr()"
end,
- capabilities = capabilities,
- -- ESLint will automatically look for config files in the project
settings = {
workingDirectory = { mode = "auto" },
},
})
end,
+
["bashls"] = function()
- local lspconfig = require("lspconfig")
lspconfig.bashls.setup({
cmd = { "bash-language-server", "start" },
filetypes = { "zsh", "bash", "sh" },
- capabilities = capabilities,
})
end,
+
["tailwindcss"] = function()
- local lspconfig = require("lspconfig")
lspconfig.tailwindcss.setup({
- includeLangauges = {
- javascript = "js",
- html = "html",
- typescript = "ts",
- typescriptreact = "tsx",
- javascriptreact = "jsx",
- },
- })
- end,
- ["lua_ls"] = function()
- local lspconfig = require("lspconfig")
- lspconfig.lua_ls.setup({
settings = {
- Lua = {
- runtime = {
- version = 'LuaJIT',
- },
- diagnostics = {
- globals = {
- 'vim',
- 'require'
- },
- },
- workspace = {
- library = vim.api.nvim_get_runtime_file("", true),
- },
- telemetry = {
- enable = false,
+ tailwindCSS = {
+ includeLanguages = {
+ javascript = "javascript",
+ typescript = "typescript",
+ javascriptreact = "javascriptreact",
+ typescriptreact = "typescriptreact",
+ html = "html",
},
},
},
diff --git a/lua/plugins/rustacean.lua b/lua/plugins/rustacean.lua
@@ -1,90 +1,54 @@
+-- lua/plugins/rustacean.lua
+---@diagnostic disable: undefined-global
return {
- 'mrcjkb/rustaceanvim',
- version = '^8',
- lazy = false,
- dependencies = {
- "mason-org/mason-registry",
- },
+ "mrcjkb/rustaceanvim",
+ version = "^9", -- or remove to track latest
+ ft = { "rust" },
config = function()
vim.g.rustaceanvim = {
tools = {
float_win_config = {
border = "rounded",
- }
+ },
},
server = {
- on_attach = function(client, bufnr)
- vim.keymap.set(
- "n",
- "<leader>a",
- function()
- vim.cmd.RustLsp('codeAction')
- end,
- { silent = true, buffer = bufnr }
- )
- vim.keymap.set(
- "n",
- "K",
- function()
- vim.cmd.RustLsp({'hover', 'actions'})
- end,
- { silent = true, buffer = bufnr }
- )
+ on_attach = function(_, bufnr)
+ local map = function(lhs, rhs, desc)
+ vim.keymap.set("n", lhs, rhs, { buffer = bufnr, silent = true, desc = desc })
+ end
+
+ map("<leader>a", function()
+ vim.cmd.RustLsp("codeAction")
+ end, "Rust code action")
+
+ map("K", function()
+ vim.cmd.RustLsp({ "hover", "actions" })
+ end, "Rust hover/actions")
end,
- cmd = { 'rust-analyzer' },
- default_settings = {
- ['rust-analyzer'] = {
- diagnostics = {
- enable = true;
- },
+
+ settings = {
+ ["rust-analyzer"] = {
+ diagnostics = { enable = true },
cargo = {
- loadOutDirsFromCheck = true,
+ loadOutDirsFromCheck = true,
allFeatures = true,
},
- },
- },
- settings = {
- ['rust-analyzer'] = {
inlayHints = {
maxLength = 50,
renderColons = true,
- bindingModeHints = {
- enable = false,
- },
- chainingHints = {
- enable = true,
- },
- closingBraceHints = {
- enable = true,
- minLines = 50,
- },
- closureCaptureTypeHints = {
- enable = true,
- },
- closureReturnTypeHints = {
- enable = true,
- },
- lifetimeElisionHints = {
- enable = true,
- useParameterNames = false,
- },
+ bindingModeHints = { enable = false },
+ chainingHints = { enable = true },
+ closingBraceHints = { enable = true, minLines = 50 },
+ closureCaptureTypeHints = { enable = true },
+ closureReturnTypeHints = { enable = true },
+ lifetimeElisionHints = { enable = true, useParameterNames = false },
genericParameterHints = {
- const = {
- enable = true,
- },
- lifetime = {
- enable = true,
- },
- type = {
- enable = true,
- },
- },
- parameterHints = {
- enable = true,
- },
- reborrowHints = {
- enable = "never",
+ const = { enable = true },
+ lifetime = { enable = true },
+ type = { enable = true },
},
+ parameterHints = { enable = true },
+ reborrowHints = { enable = "never" },
typeHints = {
enable = true,
hideClosureInitialization = false,
@@ -95,6 +59,5 @@ return {
},
},
}
-
- end
+ end,
}