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
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 = [

View file

@ -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,

View file

@ -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,
});
'';
}
];
};
};
}
};
}

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: {
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();
'';
}
];
};
};