refactor(nvim): start moving some lsp pkgs to devShells
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-21 22:30:38 -05:00
parent 054964fd66
commit e1d77a4f3b
5 changed files with 69 additions and 73 deletions

View file

@ -52,25 +52,6 @@ in {
-- https://github.com/seblj/roslyn.nvim/issues/121#issuecomment-2544076963 -- https://github.com/seblj/roslyn.nvim/issues/121#issuecomment-2544076963
vim.opt.cmdheight = 2; 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 = [ plugins = [

View file

@ -36,13 +36,13 @@ in {
mkIf cfg.enableIde mkIf cfg.enableIde
# lua # lua
'' ''
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
pattern = 'sh', pattern = 'sh',
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
require('lspconfig').bashls.setup({ require('lspconfig').bashls.setup({
capabilities = default_capabilities, capabilities = default_capabilities,

View file

@ -4,27 +4,18 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) attrValues mkIf; inherit (lib) mkIf;
inherit (pkgs.writers) writeYAML; inherit (pkgs.writers) writeYAML;
cfg = config.programs.neovim; cfg = config.programs.neovim;
in in {
mkIf cfg.enableIde { config = mkIf cfg.enableIde {
xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" { xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" {
CompileFlags.Add = ["-D__cpp_concepts=202002L"]; CompileFlags.Add = ["-D__cpp_concepts=202002L"];
}; };
programs = { programs = {
neovim = { neovim = {
extraPackages = attrValues {
inherit
(pkgs)
gcc
clang-tools
cmake-language-server
;
};
extraLuaConfig = extraLuaConfig =
# lua # lua
'' ''
@ -32,9 +23,18 @@ in
pattern = { 'cpp', 'c' }, pattern = { 'cpp', 'c' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });
'';
plugins = [
{
plugin = pkgs.vimPlugins.clangd_extensions-nvim;
type = "lua";
config =
# lua
''
local lsp = require('lspconfig'); local lsp = require('lspconfig');
local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
local clangd_extensions = require('clangd_extensions.inlay_hints'); local clangd_extensions = require('clangd_extensions.inlay_hints');
lsp.cmake.setup({ lsp.cmake.setup({
@ -52,13 +52,9 @@ in
end, end,
}); });
''; '';
plugins = attrValues {
inherit
(pkgs.vimPlugins)
clangd_extensions-nvim
;
};
};
};
} }
];
};
};
};
}

View file

@ -0,0 +1,14 @@
{
mkShell,
gcc,
clang-tools,
cmake-language-server,
...
}:
mkShell {
packages = [
gcc
clang-tools
cmake-language-server
];
}

View file

@ -1,12 +1,9 @@
self: { self: {
config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) fileContents mkBefore mkIf; inherit (lib) fileContents mkBefore;
cfg = config.programs.neovim;
in { in {
imports = [ imports = [
./bash ./bash
@ -24,8 +21,7 @@ in {
(import ./web self) (import ./web self)
]; ];
# FIXME: try making LSPs and stuff only available through devShells config.programs = {
config.programs = mkIf cfg.enableIde {
neovim = { neovim = {
extraLuaConfig = extraLuaConfig =
mkBefore mkBefore
@ -52,22 +48,16 @@ in {
lsp_status.on_attach(client); lsp_status.on_attach(client);
end, end,
}); });
-- Disable virtual_text since it's redundant due to lsp_lines.
vim.diagnostic.config({
virtual_text = false,
});
require('lsp_lines').setup();
''; '';
plugins = plugins =
(builtins.attrValues { (builtins.attrValues {
inherit inherit
(pkgs.vimPlugins) (pkgs.vimPlugins)
# lsp plugins
nvim-lspconfig nvim-lspconfig
lsp-status-nvim lsp-status-nvim
lsp_lines-nvim # completion plugins
cmp-buffer cmp-buffer
cmp-nvim-lsp cmp-nvim-lsp
cmp-path cmp-path
@ -91,6 +81,21 @@ in {
require('nvim-autopairs').setup({}); 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();
'';
}
]; ];
}; };
}; };