Something went wrong. Try again.
A very fast neovim config :D
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167local M = { { "folke/trouble.nvim", config = true, dependencies = { "nvim-tree/nvim-web-devicons" }, keys = { { "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)", }, { "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)", }, { "<leader>cs", "<cmd>Trouble symbols toggle<cr>", desc = "Symbols (Trouble)", }, { "<leader>cl", "<cmd>Trouble lsp toggle win.position=right<cr>", desc = "LSP Definitions / references / ... (Trouble)", }, { "<leader>xL", "<cmd>Trouble loclist toggle<cr>", desc = "Location List (Trouble)", }, { "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", desc = "Quickfix List (Trouble)", }, }, opts = { auto_close = true, focus = true, }, }, { "j-hui/fidget.nvim", event = "BufReadPost", opts = { notification = { override_vim_notify = true, }, }, }, { "neovim/nvim-lspconfig", event = "BufReadPre", dependencies = { { "williamboman/mason.nvim", cmd = "Mason" }, "williamboman/mason-lspconfig.nvim", }, config = function() vim.diagnostic.config({ float = { focusable = true, style = "minimal", border = "rounded", source = "always", header = "", prefix = "", severity_sort = true, }, virtual_text = { spacing = 4, prefix = "" }, signs = true, underline = true, update_in_insert = true, severity_sort = true, })
vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) local bufnr = args.buf local client = vim.lsp.get_client_by_id(args.data.client_id)
local function map(modes, keys, command, desc) vim.keymap.set(modes, keys, command, { noremap = true, silent = true, buffer = bufnr, desc = desc, }) end
map("n", "gr", "<cmd>Telescope lsp_references<CR>", "LSP References") map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", "LSP Definitions") map("n", "gD", vim.lsp.buf.declaration, "LSP Declarations") map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", "LSP Implementations") map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", "LSP Diagnostics") map("n", "<leader>d", vim.diagnostic.open_float, "Inline Diagnostics") map("n", "[d", vim.diagnostic.goto_prev, "Previous Diagnostic") map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic") map("n", "K", vim.lsp.buf.hover, "Symbol Info") map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "Code Actions") map("n", "<leader>rn", vim.lsp.buf.rename, "Smart Rename") map("i", "<C-h>", vim.lsp.buf.signature_help, "Lsp signature help") map("n", "<leader>fm", vim.lsp.buf.format, "Format Document")
if client and client:supports_method("textDocument/inlayHint") then vim.lsp.inlay_hint.enable(false, { bufnr = bufnr }) vim.keymap.set("n", "<leader>ih", function() local ih_state = not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }) vim.lsp.inlay_hint.enable(ih_state, { bufnr = bufnr }) vim.notify("Inlay hints " .. (ih_state and "enabled" or "disabled"), vim.log.levels.INFO) end, { buffer = bufnr, desc = "Toggle inlay hint" }) end end, })
local server_configs = { nil_ls = { settings = { ["nil"] = { formatting = { command = { "nixfmt" }, }, }, }, }, }
local lsp_server_env = os.getenv("LSP_SERVER")
if lsp_server_env then if not server_configs[lsp_server_env] then server_configs[lsp_server_env] = { root_markers = { ".git", ".jj", "flake.nix" }, } end
for server_name, config_opts in pairs(server_configs) do vim.lsp.config[server_name] = config_opts vim.lsp.enable(server_name) end end require("mason").setup({ ui = { border = "rounded", icons = { package_installed = "", package_pending = "", package_uninstalled = "", }, }, }) require("mason-lspconfig").setup() end, }, -- java specific shit { "artur-shaik/jc.nvim", ft = { "java" }, dependencies = { "nvim-java/nvim-java" }, opts = { keys_prefix = "<leader>j", }, },}
return M