From 502d31e03cec5e25be6b266591b954b82b500d4f Mon Sep 17 00:00:00 2001 From: Roel de Cort <63876068+dc-tec@users.noreply.github.com> Date: Mon, 26 Aug 2024 23:37:02 +0200 Subject: [PATCH] feat: small improvements (#25) - Renamed and moved settings in some plugins due to upstream changes - Added comments to neovim settings - Added cmdheight = 0 and mouse = "a" settings to config --- config/keymaps.nix | 102 +++++++--- config/plugins/editor/todo-comments.nix | 14 +- config/plugins/lsp/conform.nix | 238 ++++++++++++------------ config/plugins/ui/bufferline.nix | 31 +-- config/settings.nix | 49 +++++ 5 files changed, 275 insertions(+), 159 deletions(-) diff --git a/config/keymaps.nix b/config/keymaps.nix index d1bb12c..5669deb 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -2,54 +2,77 @@ globals.mapleader = " "; keymaps = [ - { mode = ["n" "x"]; key = "j"; action = "v:count == 0 ? 'gj' : 'j'"; - options = {expr = true; silent = true;}; + options = { + expr = true; + silent = true; + }; } { mode = ["n" "x"]; key = ""; action = "v:count == 0 ? 'gj' : 'j'"; - options = {expr = true; silent = true;}; + options = { + expr = true; + silent = true; + }; } { mode = ["n" "x"]; key = "k"; action = "v:count == 0 ? 'gk' : 'k'"; - options = {expr = true; silent = true;}; + options = { + expr = true; + silent = true; + }; } { mode = ["n" "x"]; key = ""; action = "v:count == 0 ? 'gk' : 'k'"; - options = {expr = true; silent = true;}; + options = { + expr = true; + silent = true; + }; } { mode = "n"; key = ""; action = "h"; - options = {desc = "Go to Left Window"; remap = true;}; + options = { + desc = "Go to Left Window"; + remap = true; + }; } { mode = "n"; key = ""; action = "j"; - options = {desc = "Go to Lower Window"; remap = true;}; + options = { + desc = "Go to Lower Window"; + remap = true; + }; } { mode = "n"; key = ""; action = "k"; - options = {desc = "Go to Upper Window"; remap = true;}; + options = { + desc = "Go to Upper Window"; + remap = true; + }; } { mode = "n"; key = ""; action = "l"; - options = {desc = "Go to Right Window"; remap = true;}; + options = { + desc = "Go to Right Window"; + remap = true; + }; } { mode = "n"; @@ -148,37 +171,55 @@ mode = "n"; key = "n"; action = "'Nn'[v:searchforward].'zv'"; - options = {expr = true; desc = "Next Search Result";}; + options = { + expr = true; + desc = "Next Search Result"; + }; } { mode = "x"; key = "n"; action = "'Nn'[v:searchforward]"; - options = {expr = true; desc = "Next Search Result";}; + options = { + expr = true; + desc = "Next Search Result"; + }; } { mode = "o"; key = "n"; action = "'Nn'[v:searchforward]"; - options = {expr = true; desc = "Next Search Result";}; + options = { + expr = true; + desc = "Next Search Result"; + }; } { mode = "n"; key = "N"; action = "'nN'[v:searchforward].'zv'"; - options = {expr = true; desc = "Prev Search Result";}; + options = { + expr = true; + desc = "Prev Search Result"; + }; } { mode = "x"; key = "N"; action = "'nN'[v:searchforward]"; - options = {expr = true; desc = "Prev Search Result";}; + options = { + expr = true; + desc = "Prev Search Result"; + }; } { mode = "o"; key = "N"; action = "'nN'[v:searchforward]"; - options = {expr = true; desc = "Prev Search Result";}; + options = { + expr = true; + desc = "Prev Search Result"; + }; } { mode = "n"; @@ -274,37 +315,55 @@ mode = "n"; key = "ww"; action = "p"; - options = {desc = "Other Window"; remap = true;}; + options = { + desc = "Other Window"; + remap = true; + }; } { mode = "n"; key = "wd"; action = "c"; - options = {desc = "Delete Window"; remap = true;}; + options = { + desc = "Delete Window"; + remap = true; + }; } { mode = "n"; key = "w-"; action = "s"; - options = {desc = "Split Window Below"; remap = true;}; + options = { + desc = "Split Window Below"; + remap = true; + }; } { mode = "n"; key = "w|"; action = "v"; - options = {desc = "Split Window Right"; remap = true;}; + options = { + desc = "Split Window Right"; + remap = true; + }; } { mode = "n"; key = "-"; action = "s"; - options = {desc = "Split Window Below"; remap = true;}; + options = { + desc = "Split Window Below"; + remap = true; + }; } { mode = "n"; key = "|"; action = "v"; - options = {desc = "Split Window Right"; remap = true;}; + options = { + desc = "Split Window Right"; + remap = true; + }; } { mode = "n"; @@ -344,4 +403,3 @@ } ]; } - diff --git a/config/plugins/editor/todo-comments.nix b/config/plugins/editor/todo-comments.nix index 2dafc34..ae64b80 100644 --- a/config/plugins/editor/todo-comments.nix +++ b/config/plugins/editor/todo-comments.nix @@ -1,12 +1,14 @@ _: { plugins.todo-comments = { enable = true; - colors = { - error = ["DiagnosticError" "ErrorMsg" "#ED8796"]; - warning = ["DiagnosticWarn" "WarningMsg" "#EED49F"]; - info = ["DiagnosticInfo" "#EED49F"]; - default = ["Identifier" "#F5A97F"]; - test = ["Identifier" "#8AADF4"]; + settings = { + colors = { + error = ["DiagnosticError" "ErrorMsg" "#ED8796"]; + warning = ["DiagnosticWarn" "WarningMsg" "#EED49F"]; + info = ["DiagnosticInfo" "#EED49F"]; + default = ["Identifier" "#F5A97F"]; + test = ["Identifier" "#8AADF4"]; + }; }; }; } diff --git a/config/plugins/lsp/conform.nix b/config/plugins/lsp/conform.nix index 206b3ee..e3f3b01 100644 --- a/config/plugins/lsp/conform.nix +++ b/config/plugins/lsp/conform.nix @@ -41,128 +41,130 @@ ''; plugins.conform-nvim = { enable = true; - formatOnSave = '' - function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - - if slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end - - local function on_format(err) - if err and err:match("timeout$") then - slow_format_filetypes[vim.bo[bufnr].filetype] = true + settings = { + format_on_save = '' + function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return end + + if slow_format_filetypes[vim.bo[bufnr].filetype] then + return + end + + local function on_format(err) + if err and err:match("timeout$") then + slow_format_filetypes[vim.bo[bufnr].filetype] = true + end + end + + return { timeout_ms = 200, lsp_fallback = true }, on_format + end + ''; + + format_after_save = '' + function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + + if not slow_format_filetypes[vim.bo[bufnr].filetype] then + return + end + + return { lsp_fallback = true } end + ''; + notify_on_error = true; + formatters_by_ft = { + html = [ + [ + "prettierd" + "prettier" + ] + ]; + css = [ + [ + "prettierd" + "prettier" + ] + ]; + javascript = [ + [ + "prettierd" + "prettier" + ] + ]; + typescript = [ + [ + "prettierd" + "prettier" + ] + ]; + python = [ + "black" + "isort" + ]; + lua = ["stylua"]; + nix = ["alejandra"]; + markdown = [ + [ + "prettierd" + "prettier" + ] + ]; + yaml = [ + [ + "prettierd" + "prettier" + ] + ]; + terraform = ["terraform_fmt"]; + bicep = ["bicep"]; + bash = [ + "shellcheck" + "shellharden" + "shfmt" + ]; + json = ["jq"]; + "_" = ["trim_whitespace"]; + }; - return { timeout_ms = 200, lsp_fallback = true }, on_format - end - ''; - - formatAfterSave = '' - function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - - if not slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end - - return { lsp_fallback = true } - end - ''; - notifyOnError = true; - formattersByFt = { - html = [ - [ - "prettierd" - "prettier" - ] - ]; - css = [ - [ - "prettierd" - "prettier" - ] - ]; - javascript = [ - [ - "prettierd" - "prettier" - ] - ]; - typescript = [ - [ - "prettierd" - "prettier" - ] - ]; - python = [ - "black" - "isort" - ]; - lua = ["stylua"]; - nix = ["alejandra"]; - markdown = [ - [ - "prettierd" - "prettier" - ] - ]; - yaml = [ - [ - "prettierd" - "prettier" - ] - ]; - terraform = ["terraform_fmt"]; - bicep = ["bicep"]; - bash = [ - "shellcheck" - "shellharden" - "shfmt" - ]; - json = ["jq"]; - "_" = ["trim_whitespace"]; - }; - - formatters = { - black = { - command = "${lib.getExe pkgs.black}"; + formatters = { + black = { + command = "${lib.getExe pkgs.black}"; + }; + isort = { + command = "${lib.getExe pkgs.isort}"; + }; + alejandra = { + command = "${lib.getExe pkgs.alejandra}"; + }; + jq = { + command = "${lib.getExe pkgs.jq}"; + }; + prettierd = { + command = "${lib.getExe pkgs.prettierd}"; + }; + stylua = { + command = "${lib.getExe pkgs.stylua}"; + }; + shellcheck = { + command = "${lib.getExe pkgs.shellcheck}"; + }; + shfmt = { + command = "${lib.getExe pkgs.shfmt}"; + }; + shellharden = { + command = "${lib.getExe pkgs.shellharden}"; + }; + bicep = { + command = "${lib.getExe pkgs.bicep}"; + }; + #yamlfmt = { + # command = "${lib.getExe pkgs.yamlfmt}"; + #}; }; - isort = { - command = "${lib.getExe pkgs.isort}"; - }; - alejandra = { - command = "${lib.getExe pkgs.alejandra}"; - }; - jq = { - command = "${lib.getExe pkgs.jq}"; - }; - prettierd = { - command = "${lib.getExe pkgs.prettierd}"; - }; - stylua = { - command = "${lib.getExe pkgs.stylua}"; - }; - shellcheck = { - command = "${lib.getExe pkgs.shellcheck}"; - }; - shfmt = { - command = "${lib.getExe pkgs.shfmt}"; - }; - shellharden = { - command = "${lib.getExe pkgs.shellharden}"; - }; - bicep = { - command = "${lib.getExe pkgs.bicep}"; - }; - #yamlfmt = { - # command = "${lib.getExe pkgs.yamlfmt}"; - #}; }; }; }; diff --git a/config/plugins/ui/bufferline.nix b/config/plugins/ui/bufferline.nix index e7d1a3f..e865c7c 100644 --- a/config/plugins/ui/bufferline.nix +++ b/config/plugins/ui/bufferline.nix @@ -2,23 +2,28 @@ plugins = { bufferline = { enable = true; - diagnostics = "nvim_lsp"; - mode = "buffers"; + settings = { + options = { + diagnostics = "nvim_lsp"; + mode = "buffers"; - closeIcon = " "; - bufferCloseIcon = "󰱝 "; - modifiedIcon = "󰔯 "; + close_icon = " "; + buffer_close_icon = "󰱝 "; + modified_icon = "󰔯 "; - offsets = [ - { - filetype = "neo-tree"; - text = "Neo-tree"; - highlight = "Directory"; - text_align = "left"; - } - ]; + offsets = [ + { + filetype = "neo-tree"; + text = "Neo-tree"; + highlight = "Directory"; + text_align = "left"; + } + ]; + }; + }; }; }; + keymaps = [ { mode = "n"; diff --git a/config/settings.nix b/config/settings.nix index 7a8ead0..96fd9be 100644 --- a/config/settings.nix +++ b/config/settings.nix @@ -14,29 +14,78 @@ }; opts = { + # Show line numbers number = true; + + # Show relative line numbers relativenumber = true; + + # Use the system clipboard clipboard = "unnamedplus"; + + # Number of spaces that represent a tabstop = 2; softtabstop = 2; + + # Show tabline always showtabline = 2; + + # Use spaces instead of tabs expandtab = true; + + # Enable smart indentation smartindent = true; + + # Number of spaces to use for each step of (auto)indent shiftwidth = 2; + + # Enable break indent breakindent = true; + + # Highlight the screen line of the cursor cursorline = true; + + # Minimum number of screen lines to keep above and below the cursor scrolloff = 8; + + # Enable mouse support + mouse = "a"; + + # Set folding method to manual foldmethod = "manual"; + + # Disable folding by default foldenable = false; + + # Wrap long lines at a character in 'breakat' linebreak = true; + + # Disable spell checking spell = false; + + # Disable swap file creation swapfile = false; + + # Time in milliseconds to wait for a mapped sequence to complete timeoutlen = 300; + + # Enable 24-bit RGB color in the TUI termguicolors = true; + + # Don't show mode in the command line showmode = false; + + # Open new split below the current window splitbelow = true; + + # Keep the screen when splitting splitkeep = "screen"; + + # Open new split to the right of the current window splitright = true; + + # Hide command line unless needed + cmdheight = 0; }; }; }