Add more lsp support, completions in nvim via coq

This commit is contained in:
Grimmauld 2024-05-15 17:37:03 +02:00
parent b72e2a05bd
commit 7b2265b906
Signed by: Grimmauld
GPG Key ID: C2946668769F91FB
6 changed files with 183 additions and 60 deletions

View File

@ -13,7 +13,6 @@ let
getExe
optionals
mkIf
concatLines
;
in
{
@ -22,6 +21,9 @@ in
./nix.nix
./security.nix
./python.nix
./rust.nix
./nvim.nix
./lsp.nix
];
config = mkIf (enable && tooling.enable) {
@ -35,14 +37,11 @@ in
urlencode
pstree
dos2unix
treefmt
file
wget
hyfetch
util-linux
btop
neovim-remote
linuxPackages.perf
eza
@ -82,7 +81,6 @@ in
config = {
init.defaultBranch = "main";
credential.username = tooling.git_user;
core.editor = getExe pkgs.neovim;
user.name = tooling.git_user;
user.email = tooling.git_email;
push.autoSetupRemote = true;
@ -113,46 +111,9 @@ in
services.dbus.implementation = "broker";
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [
fugitive
nvim-lspconfig
];
};
boot.tmp.cleanOnBoot = true;
zramSwap.enable = true;
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
luafile ${luarc}
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
endif
'';
packages.myVimPackage = {
start = tooling.nvim.plugins;
opt = [ ];
};
};
};
programs.ssh = {
startAgent = true;
enableAskPassword = graphical;
@ -163,21 +124,6 @@ in
options.grimmShared.tooling = {
enable = mkEnableOption "grimm-tooling";
nvim = {
plugins = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Extra vim plugins to include";
};
extraLuaRC = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
description = "Extra init LUA scripts";
};
};
git_user = mkOption {
type = types.str;
default = "Grimmauld";

68
common/tooling/lsp.nix Normal file
View File

@ -0,0 +1,68 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
mkIf
getName
mkEnableOption
filter
;
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages = map (v: v.package) tooling.lang_servers;
grimmShared.tooling.nvim.extraLuaRC =
[ "vim.g.coq_settings = { auto_start = 'shut-up' }" ]
++ (map (
v: "require'lspconfig'.${v.name}.setup(require('coq').lsp_ensure_capabilities(${v.config}))"
) (filter (v: v.vimIntegration) tooling.lang_servers));
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
nvim-lspconfig
coq_nvim
coq-artifacts
];
};
options.grimmShared.tooling.lang_servers = mkOption {
type = types.listOf (
types.submodule (
{ config, ... }:
{
options = {
name = mkOption {
type = types.nullOr types.nonEmptyStr;
default = getName config.package;
description = "lspconfig module name";
};
config = mkOption {
type = types.nonEmptyStr;
default = "{}";
description = "options to pass to lspconfig";
};
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // {
default = true;
};
package = mkOption {
type = types.package;
description = "LSP package";
};
};
}
)
);
default = { };
description = "Language servers available on the system";
};
}

View File

@ -18,9 +18,11 @@
environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; };
grimmShared.tooling.nvim.extraLuaRC = lib.singleton ''
require'lspconfig'.nixd.setup{}
'';
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [ vim-nix ];
};
grimmShared.tooling.lang_servers = [ { package = pkgs.nixd; } ];
nix.settings = {
experimental-features = [

74
common/tooling/nvim.nix Normal file
View File

@ -0,0 +1,74 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
getExe
mkIf
concatLines
;
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages = with pkgs; [
dos2unix
treefmt
neovim-remote
];
programs.git.config.core.editor = getExe pkgs.neovim;
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ fugitive ];
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
withPython3 = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
luafile ${luarc}
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
endif
'';
packages.myVimPackage = {
start = tooling.nvim.plugins;
opt = [ ];
};
};
};
};
options.grimmShared.tooling.nvim = {
plugins = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Extra vim plugins to include";
};
extraLuaRC = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
description = "Extra init LUA scripts";
};
};
}

View File

@ -19,6 +19,8 @@ in
config = lib.mkIf (enable && tooling.enable) {
environment.systemPackages = [
(pkgs.python3.withPackages pyLibs)
pkgs.yapf
pkgs.pyright
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
programs.xonsh = {
@ -30,5 +32,9 @@ in
);
package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; };
};
grimmShared.tooling.nvim.extraLuaRC = lib.singleton ''
require'lspconfig'.pyright.setup{}
'';
};
}

27
common/tooling/rust.nix Normal file
View File

@ -0,0 +1,27 @@
{
pkgs,
lib,
config,
...
}:
let
inherit (config.grimmShared) enable tooling graphical;
in
{
config = lib.mkIf (enable && tooling.enable) {
environment.systemPackages =
with pkgs;
[
rustfmt
pkg-config
]
++ lib.optionals graphical [ jetbrains.clion ];
grimmShared.tooling.lang_servers = [
{
package = pkgs.rust-analyzer;
name = "rust_analyzer";
}
];
};
}