diff --git a/homeManagerModules/neovim/default.nix b/homeManagerModules/neovim/default.nix index e1008220..d68baea1 100644 --- a/homeManagerModules/neovim/default.nix +++ b/homeManagerModules/neovim/default.nix @@ -52,25 +52,6 @@ in { -- https://github.com/seblj/roslyn.nvim/issues/121#issuecomment-2544076963 vim.opt.cmdheight = 2; - - -- Get rid of deprecated messages - vim.tbl_add_reverse_lookup = function(tbl) - for k, v in pairs(tbl) do - tbl[v] = k; - end - end; - vim.tbl_islist = function(tbl) - return vim.islist(tbl); - end; - vim.diagnostic.is_disabled = function() - return not vim.diagnostic.is_enabled(); - end; - vim.lsp.buf_get_clients = function() - return vim.lsp.get_clients(); - end; - vim.lsp.get_active_clients = function() - return vim.lsp.get_clients(); - end; ''; plugins = [ diff --git a/homeManagerModules/neovim/langs/bash/default.nix b/homeManagerModules/neovim/langs/bash/default.nix index 5c12e4c3..d4215ba8 100644 --- a/homeManagerModules/neovim/langs/bash/default.nix +++ b/homeManagerModules/neovim/langs/bash/default.nix @@ -36,13 +36,13 @@ in { mkIf cfg.enableIde # lua '' - local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); - vim.api.nvim_create_autocmd('FileType', { pattern = 'sh', command = 'setlocal ts=4 sw=4 sts=0 expandtab', }); + local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); + require('lspconfig').bashls.setup({ capabilities = default_capabilities, diff --git a/homeManagerModules/neovim/langs/c-lang/default.nix b/homeManagerModules/neovim/langs/c-lang/default.nix index 91d311b6..ae4ca2dc 100644 --- a/homeManagerModules/neovim/langs/c-lang/default.nix +++ b/homeManagerModules/neovim/langs/c-lang/default.nix @@ -4,27 +4,18 @@ pkgs, ... }: let - inherit (lib) attrValues mkIf; + inherit (lib) mkIf; inherit (pkgs.writers) writeYAML; cfg = config.programs.neovim; -in - mkIf cfg.enableIde { +in { + config = mkIf cfg.enableIde { xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" { CompileFlags.Add = ["-D__cpp_concepts=202002L"]; }; programs = { neovim = { - extraPackages = attrValues { - inherit - (pkgs) - gcc - clang-tools - cmake-language-server - ; - }; - extraLuaConfig = # lua '' @@ -32,33 +23,38 @@ in pattern = { 'cpp', 'c' }, command = 'setlocal ts=4 sw=4 sts=0 expandtab', }); - - local lsp = require('lspconfig'); - local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); - local clangd_extensions = require('clangd_extensions.inlay_hints'); - - lsp.cmake.setup({ - capabilities = default_capabilities, - }); - - lsp.clangd.setup({ - capabilities = default_capabilities, - - handlers = require('lsp-status').extensions.clangd.setup(), - - on_attach = function(_, bufnr) - clangd_extensions.setup_autocmd(); - clangd_extensions.set_inlay_hints(); - end, - }); ''; - plugins = attrValues { - inherit - (pkgs.vimPlugins) - clangd_extensions-nvim - ; - }; + plugins = [ + { + plugin = pkgs.vimPlugins.clangd_extensions-nvim; + type = "lua"; + config = + # lua + '' + local lsp = require('lspconfig'); + local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); + + local clangd_extensions = require('clangd_extensions.inlay_hints'); + + lsp.cmake.setup({ + capabilities = default_capabilities, + }); + + lsp.clangd.setup({ + capabilities = default_capabilities, + + handlers = require('lsp-status').extensions.clangd.setup(), + + on_attach = function(_, bufnr) + clangd_extensions.setup_autocmd(); + clangd_extensions.set_inlay_hints(); + end, + }); + ''; + } + ]; }; }; - } + }; +} diff --git a/homeManagerModules/neovim/langs/c-lang/devShell.nix b/homeManagerModules/neovim/langs/c-lang/devShell.nix new file mode 100644 index 00000000..dc47baaa --- /dev/null +++ b/homeManagerModules/neovim/langs/c-lang/devShell.nix @@ -0,0 +1,14 @@ +{ + mkShell, + gcc, + clang-tools, + cmake-language-server, + ... +}: +mkShell { + packages = [ + gcc + clang-tools + cmake-language-server + ]; +} diff --git a/homeManagerModules/neovim/langs/default.nix b/homeManagerModules/neovim/langs/default.nix index fe042aee..76b17290 100644 --- a/homeManagerModules/neovim/langs/default.nix +++ b/homeManagerModules/neovim/langs/default.nix @@ -1,12 +1,9 @@ self: { - config, lib, pkgs, ... }: let - inherit (lib) fileContents mkBefore mkIf; - - cfg = config.programs.neovim; + inherit (lib) fileContents mkBefore; in { imports = [ ./bash @@ -24,8 +21,7 @@ in { (import ./web self) ]; - # FIXME: try making LSPs and stuff only available through devShells - config.programs = mkIf cfg.enableIde { + config.programs = { neovim = { extraLuaConfig = mkBefore @@ -52,22 +48,16 @@ in { lsp_status.on_attach(client); end, }); - - -- Disable virtual_text since it's redundant due to lsp_lines. - vim.diagnostic.config({ - virtual_text = false, - }); - - require('lsp_lines').setup(); ''; plugins = (builtins.attrValues { inherit (pkgs.vimPlugins) + # lsp plugins nvim-lspconfig lsp-status-nvim - lsp_lines-nvim + # completion plugins cmp-buffer cmp-nvim-lsp cmp-path @@ -91,6 +81,21 @@ in { require('nvim-autopairs').setup({}); ''; } + + { + plugin = pkgs.vimPlugins.lsp_lines-nvim; + type = "lua"; + config = + # lua + '' + -- Disable virtual_text since it's redundant due to lsp_lines. + vim.diagnostic.config({ + virtual_text = false, + }); + + require('lsp_lines').setup(); + ''; + } ]; }; };