if vim.g.neovide then vim.o.guifont = "FantasqueSansM Nerd Font:h10" vim.g.neovide_cursor_animation_length = 0.1 vim.g.neovide_cursor_trail_size = 0.2 vim.g.neovide_cursor_vfx_mode = "sonicboom" vim.g.neovide_cursor_animate_command_line = false end vim.go.mouse = "a" vim.go.showmode = false vim.go.termguicolors = true vim.go.shell = "fish" vim.go.completeopt = "menuone,noinsert,noselect,preview" vim.go.expandtab = false -- Tabs over spaces because accessibility. vim.go.shiftwidth = 2 vim.go.tabstop = 2 vim.go.listchars="tab:⇤–⇥,space:·,trail:·,precedes:⇠,extends:⇢,nbsp:×" vim.wo.list = true vim.wo.number = true -- Case insensitive searching UNLESS /C or capital in search vim.o.ignorecase = true vim.o.smartcase = true vim.o.hlsearch = false vim.g.mapleader = " " local lsp_servers = { clangd = {}, biome = {}, nil_ls = {}, pylsp = { pylsp = { configurationSources = "flake8", plugins = { pycodestyle = { enabled = false } } } }, rust_analyzer = { checkOnSave = { command = "clippy", }, }, } vim.api.nvim_create_autocmd("TermOpen", { command = "setlocal nonumber", }) vim.api.nvim_create_autocmd("TermOpen", { command = "startinsert" }) vim.keymap.set("n", "t", "below split | terminal", { desc = "open terminal" }) vim.keymap.set("n", "e", "Neotree toggle reveal", { desc = "Reveal neotree" }) vim.keymap.set("n", "wv", "vsplit", { desc = "tall split" }) vim.keymap.set("n", "ws", "split", { desc = "wide split" }) vim.keymap.set("n", "wr", "winc r", { desc = "swap windows" }) vim.keymap.set("n", "ww", "winc w", { desc = "next window" }) vim.keymap.set("n", "wn", "winc w", { desc = "next window" }) vim.keymap.set("n", "wd", "quit", { desc = "close window" }) vim.keymap.set("n", "wq", "quit", { desc = "close window" }) vim.keymap.set("n", "bn", "bn", { desc = "next buffer" }) vim.keymap.set("n", "bp", "bp", { desc = "prev buffer" }) vim.keymap.set("n", "bd", "bd", { desc = "close buffer" }) vim.keymap.set("n", "bc", "bd", { desc = "close buffer" }) vim.keymap.set("n", "bl", require('telescope.builtin').buffers, { desc = "list buffers" }) vim.keymap.set("n", "/", require('telescope.builtin').live_grep, { desc = "grep" }) vim.keymap.set('n', 'd', require('telescope.builtin').diagnostics, { desc = "diagnostics"}) vim.keymap.set("n", "ff", require('telescope.builtin').find_files, { desc = "find files" }) vim.keymap.set("n", "fd", require('telescope').extensions.zoxide.list, { desc = "change directory" }) vim.keymap.set("n", "fr", require('telescope.builtin').oldfiles, { desc = "recent files" }) local custom_attach = function(client, bufnr) -- Mapping helper function. local kmap = function(key, cmd, desc) vim.keymap.set("n", key, cmd, {silent = true, buffer = bufnr, desc = desc }) end kmap('K', vim.lsp.buf.hover, 'Hover Documentation') kmap('', vim.lsp.buf.signature_help, 'Signature Documentation') kmap("gd", vim.lsp.buf.definition, "goto definition") kmap("gr", require('telescope.builtin').lsp_references, "show references") kmap("lr", vim.lsp.buf.rename, "rename variable") kmap("ls", require('telescope.builtin').lsp_workspace_symbols, "search symbols") kmap("la", vim.lsp.buf.code_action, "code action") kmap("lwa", vim.lsp.buf.add_workspace_folder, "add workspace folder") kmap("lwr", vim.lsp.buf.remove_workspace_folder, "remove workspace folder") kmap("lwl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, "list workspace folder") -- Set some key bindings conditional on server capabilities if client.server_capabilities.documentFormattingProvider then kmap("lf", vim.lsp.buf.format, "format code") end vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_buf_set_option(bufnr, "completefunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_create_autocmd("CursorHold", { buffer = bufnr, callback = function() local float_opts = { focusable = false, close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, border = "rounded", source = "always", -- show source in diagnostic popup window prefix = " ", } if #vim.diagnostic.get() > 0 then vim.diagnostic.open_float(nil, float_opts) end end }) if vim.g.logging_level == "debug" then local msg = string.format("Language server %s started!", client.name) vim.notify(msg, vim.log.levels.DEBUG, { title = "Nvim-config" }) end end local capabilities = vim.lsp.protocol.make_client_capabilities() -- Configure each server local lspconfig = require 'lspconfig' for server_name, config in pairs(lsp_servers) do lspconfig[server_name].setup { capabilities = capabilities, on_attach = custom_attach, settings = config, } end -- Change diagnostic signs. vim.fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" }) vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) vim.fn.sign_define("DiagnosticSignHint", { text = ">", texthl = "DiagnosticSignHint" }) -- global config for diagnostic vim.diagnostic.config { underline = false, virtual_text = false, signs = true, severity_sort = true, } -- vim: ts=2 sw=2