--- Basic lua installation lines. local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release lazypath, }) end -- NOTE: Refer to :h vim.lsp.config() for more information. vim.lsp.config("*", { capabilities = vim.lsp.protocol.make_client_capabilities(), }) vim.opt.rtp:prepend(lazypath) require("lazy").setup({ { import = "ache.plugins.themes" }, { import = "ache.plugins" }, { import = "ache.plugins.lsp" }, -- Load Language Server Protocol plugins for code completion, diagnostics and context aware actions. { import = "ache.plugins.llm" }, -- Load Large Language Models related plugins (Mostly code completion) { import = "ache.plugins.dap" }, -- Load debugging tools, Debug Adapter Protocol }, { checker = { enabled = true, notify = false, }, change_detection = { notify = false, }, ui = { custom_keys = { -- You can define custom keymaps here. If present, the description will -- be shown in the help menu. -- To disable one of the defaults, set it to false. ["tl"] = { function(plugin) require("lazy.util").float_term({ "lazygit", "log" }, { cwd = plugin.dir, }) end, desc = "Open lazygit log", }, ["ti"] = { function(plugin) Util.notify(vim.inspect(plugin), { title = "Inspect " .. plugin.name, lang = "lua", }) end, desc = "Inspect Plugin", }, ["tt"] = { function(plugin) require("lazy.util").float_term(nil, { cwd = plugin.dir, }) end, desc = "Open terminal in plugin dir", }, }, }, }) -- Will list every Lua file in the directory and load them. -- LSP config vim.lsp.enable("pyright") vim.lsp.enable("rust_analyzer") vim.lsp.enable("lua_ls") vim.lsp.enable("clangd") vim.lsp.enable("gopls") vim.lsp.enable("html") vim.lsp.enable("cssls") local capabilities = require("cmp_nvim_lsp").default_capabilities() vim.lsp.config("*", { capabilities = capabilities, }) vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(args) --[[ local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) if client:supports_method("textDocument/implementation") then -- Create a keymap for vim.lsp.buf.implementation ... end -- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y| if client:supports_method("textDocument/completion") then -- Optional: trigger autocompletion on EVERY keypress. May be slow! -- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end -- client.server_capabilities.completionProvider.triggerCharacters = chars vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) end -- Auto-format ("lint") on save. -- Usually not needed if server supports "textDocument/willSaveWaitUntil". if not client:supports_method("textDocument/willSaveWaitUntil") and client:supports_method("textDocument/formatting") then vim.api.nvim_create_autocmd("BufWritePre", { group = vim.api.nvim_create_augroup("UserLspConfig", { clear = false }), buffer = args.buf, callback = function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) end, }) end --]] local map = function(keys, func, desc) vim.keymap.set("n", keys, func, { buffer = args.buf, desc = "Lsp: " .. desc }) end local tele_defs_action = "Telescope lsp_definitions" local tele_refs_action = "Telescope lsp_references" local tele_impl_action = "Telescope lsp_implementations" local tele_typedefs_action = "Telescope lsp_type_definitions" local tele_diag_action = "Telescope diagnostics bufnr=0" local tele = require("telescope.builtin") -- map("g", tele.lsp_definitions, "Goto Definition") map("ls", tele.lsp_document_symbols, "Doc Symbols") map("lS", tele.lsp_dynamic_workspace_symbols, "Dynamic Symbols") -- map("fh", tele.lsp_dynamic_help, "Help") map("lr", tele.lsp_references, "Goto References") map("li", tele.lsp_implementations, "Goto Implementations") map("K", vim.lsp.buf.hover, "Show documentation") map("E", vim.diagnostic.open_float, "Open Diagnostics") map("k", vim.lsp.buf.signature_help, "Signature Help") map("rn", vim.lsp.buf.rename, "Rename") map("lf", vim.lsp.buf.format, "Format") map("gR", "Telescope lsp_references", "Show LSP references") map("gD", vim.lsp.buf.declaration, "Go to declaration") map("gd", tele_defs_action, "Show LSP definitions") map("gi", tele_impl_action, "Show LSP implementations") map("gt", tele_typedefs_action, "Show LSP type definitions") map("D", tele_diag_action, "Show buffer diagnostics") map("d", vim.diagnostic.open_float, "Show line diagnostics") map(">d", vim.diagnostic.goto_next, "Go to next diagnostic") map("rs", "LspRestart", "Restart LSP") map("ss", "LspStop harper_ls", "Stop harper-ls, The spell checking plugin") map("sS", "LspRestart harper_ls", "(Re)-start harper-ls, The spell checking plugin") vim.keymap.set( { "n", "v" }, "ca", vim.lsp.buf.code_action, { buffer = args.buf, desc = "Lsp: See available code actions" } ) vim.keymap.set( "n", "lt", require("ache.diagnostics").line_diagnostics, { buffer = args.buf, silent = true, desc = "Show diagnostics tools used" } ) end, })