From 946a1f929f915f18f378c2c6bfb4a9566f2c7386 Mon Sep 17 00:00:00 2001 From: Bailey Stevens Date: Mon, 19 Feb 2024 14:29:55 -0500 Subject: [PATCH] Indentation and formatting changes for nvim config --- modules/home/neovim/nvim.lua | 156 ++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 77 deletions(-) diff --git a/modules/home/neovim/nvim.lua b/modules/home/neovim/nvim.lua index 611d584..e18288e 100644 --- a/modules/home/neovim/nvim.lua +++ b/modules/home/neovim/nvim.lua @@ -1,10 +1,10 @@ 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 + 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" @@ -12,7 +12,7 @@ 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.expandtab = true vim.go.shiftwidth = 2 vim.go.tabstop = 2 @@ -29,31 +29,31 @@ 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", - }, - }, + 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", + command = "setlocal nonumber", }) vim.api.nvim_create_autocmd("TermOpen", { - command = "startinsert" + command = "startinsert" }) vim.keymap.set("n", "t", "below split | terminal", { desc = "open terminal" }) @@ -74,62 +74,64 @@ 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", "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" }) +vim.keymap.set("n", "c=", "retab", { desc = "normalize indentation" }) + 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 + -- 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('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("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("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") + 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 + -- 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_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 = " ", - } + 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.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 + 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() @@ -137,11 +139,11 @@ 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, - } + lspconfig[server_name].setup { + capabilities = capabilities, + on_attach = custom_attach, + settings = config, + } end -- Change diagnostic signs. @@ -152,10 +154,10 @@ vim.fn.sign_define("DiagnosticSignHint", { text = ">", texthl = "DiagnosticSignH -- global config for diagnostic vim.diagnostic.config { - underline = false, - virtual_text = false, - signs = true, - severity_sort = true, + underline = false, + virtual_text = false, + signs = true, + severity_sort = true, } -- vim: ts=2 sw=2