From b54035b68dba27043e4a7cda1757e20510c717e9 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 24 Jun 2025 16:31:38 -0400 Subject: make neovim lsps toggle with development options --- home/neovim/config.nix | 186 ++++++++++++++++++++++++++---------------------- home/neovim/default.nix | 2 +- 2 files changed, 100 insertions(+), 88 deletions(-) (limited to 'home') diff --git a/home/neovim/config.nix b/home/neovim/config.nix index 4ded0e9..8e04b84 100644 --- a/home/neovim/config.nix +++ b/home/neovim/config.nix @@ -1,94 +1,106 @@ { + lib, config, self, -}: -self.lib.toLua { - # Width of tabs in the editor - tabwidth = 4; - # If tabs should be expanded to spaces - expandtab = false; - keys = { - # NeoVIM leader key - leader = " "; - # Keybind to remove active hilighted content - noh = "h"; - menus = { - # Open file browser - browser = "e"; - # Show active buffers - buffers = "fb"; - # Show LSP errors - error = "t"; - # Find files in working directory - find = "ff"; - # Grep files in working directory - grep = "fg"; - # Search help menu - help = "fh"; - # Voew undo tree - undo = "u"; +}: let + inherit (lib) optionalAttrs; +in + self.lib.toLua { + # Width of tabs in the editor + tabwidth = 4; + # If tabs should be expanded to spaces + expandtab = false; + keys = { + # NeoVIM leader key + leader = " "; + # Keybind to remove active hilighted content + noh = "h"; + menus = { + # Open file browser + browser = "e"; + # Show active buffers + buffers = "fb"; + # Show LSP errors + error = "t"; + # Find files in working directory + find = "ff"; + # Grep files in working directory + grep = "fg"; + # Search help menu + help = "fh"; + # Voew undo tree + undo = "u"; + }; + lsp = { + # Open LSP hover menu on a value + hover = "K"; + # Perform an LSP action on a value + action = "la"; + # View all references of a value + references = "lr"; + # Rename current and all references of a value + rename = "ln"; + }; + cmp = { + # Select previous value in completion engine + prev = ""; + # Select next value in completion engine + next = ""; + # Confirm current value in completion engine + confirm = ""; + # Auto complete using completion engine + complete = ""; + }; }; - lsp = { - # Open LSP hover menu on a value - hover = "K"; - # Perform an LSP action on a value - action = "la"; - # View all references of a value - references = "lr"; - # Rename current and all references of a value - rename = "ln"; + # list of lsp servers to load + lsps = + optionalAttrs config.development.c { + clangd = {}; + } + // optionalAttrs config.development.java { + jdtls = {}; + kotlin_language_server = {}; + } + // optionalAttrs config.development.rust { + rust_analyzer = {}; + } + // optionalAttrs config.development.web { + ts_ls = {}; + phpactor = {}; + } + // optionalAttrs config.development.zig { + zls = {}; + }; + highlight = { + # max file size in KiB to attempt to parse + max_size = 1024; }; - cmp = { - # Select previous value in completion engine - prev = ""; - # Select next value in completion engine - next = ""; - # Confirm current value in completion engine - confirm = ""; - # Auto complete using completion engine - complete = ""; + # colorscheme + theme = { + colors = { + base00 = "#${config.theme.colors.bg}"; + base01 = "#${config.theme.colors.surface.bg}"; + base02 = "#${config.theme.colors.surface.bg}"; + base03 = "#${config.theme.colors.bright.white}"; + base04 = "#${config.theme.colors.bright.black}"; + base05 = "#${config.theme.colors.fg}"; + base06 = "#${config.theme.colors.bright.white}"; + base07 = "#${config.theme.colors.hover.bg}"; + base08 = "#${config.theme.colors.bright.red}"; + base09 = "#${config.theme.colors.bright.yellow}"; + base0A = "#${config.theme.colors.bright.yellow}"; + base0B = "#${config.theme.colors.bright.green}"; + base0C = "#${config.theme.colors.bright.cyan}"; + base0D = "#${config.theme.colors.bright.blue}"; + base0E = "#${config.theme.colors.bright.magenta}"; + base0F = "#${config.theme.colors.normal.yellow}"; + }; + transparent = true; }; - }; - # list of lsp servers to load - lsps = { - clangd = {}; - jdtls = {}; - kotlin_language_server = {}; - phpactor = {}; - rust_analyzer = {}; - ts_ls = {}; - zls = {}; - }; - highlight = { - # max file size in KiB to attempt to parse - max_size = 1024; - }; - # colorscheme - theme = { - colors = { - base00 = "#${config.theme.colors.bg}"; - base01 = "#${config.theme.colors.surface.bg}"; - base02 = "#${config.theme.colors.surface.bg}"; - base03 = "#${config.theme.colors.bright.white}"; - base04 = "#${config.theme.colors.bright.black}"; - base05 = "#${config.theme.colors.fg}"; - base06 = "#${config.theme.colors.bright.white}"; - base07 = "#${config.theme.colors.hover.bg}"; - base08 = "#${config.theme.colors.bright.red}"; - base09 = "#${config.theme.colors.bright.yellow}"; - base0A = "#${config.theme.colors.bright.yellow}"; - base0B = "#${config.theme.colors.bright.green}"; - base0C = "#${config.theme.colors.bright.cyan}"; - base0D = "#${config.theme.colors.bright.blue}"; - base0E = "#${config.theme.colors.bright.magenta}"; - base0F = "#${config.theme.colors.normal.yellow}"; + # max column width + col = { + # show a bar at `width` characters + show = true; + width = 80; }; - transparent = true; - }; - # max column width - col = { - # show a bar at `width` characters - show = true; - width = 80; - }; -} + } diff --git a/home/neovim/default.nix b/home/neovim/default.nix index 559bdf0..7d3f331 100644 --- a/home/neovim/default.nix +++ b/home/neovim/default.nix @@ -5,7 +5,7 @@ self, ... }: let - lua_cfg = import ./config.nix {inherit config self;}; + lua_cfg = import ./config.nix {inherit lib config self;}; lua = builtins.readFile ./init.lua; in { environment.variables.EDITOR = "nvim"; -- cgit v1.2.3-freya