parent
3348300ab7
commit
ac2b846662
18 changed files with 563 additions and 315 deletions
common/home/neovim/langs
44
common/home/neovim/langs/bash.nix
Normal file
44
common/home/neovim/langs/bash.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) neovimIde;
|
||||
inherit (pkgs) vimPlugins;
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
programs = {
|
||||
# I love doing typos
|
||||
bash.shellAliases = {
|
||||
nivm = "nvim";
|
||||
nivim = "nvim";
|
||||
};
|
||||
|
||||
neovim = {
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
||||
extraLuaConfig =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = 'sh',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
'';
|
||||
|
||||
coc.settings = {
|
||||
# Bash
|
||||
bashIde.shellcheckPath = "${pkgs.shellcheck}/bin/shellcheck";
|
||||
};
|
||||
|
||||
plugins = [
|
||||
vimPlugins.coc-sh
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
24
common/home/neovim/langs/clang.nix
Normal file
24
common/home/neovim/langs/clang.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) neovimIde;
|
||||
inherit (pkgs) vimPlugins;
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = with pkgs; [
|
||||
gcc
|
||||
clang-tools
|
||||
];
|
||||
|
||||
plugins = [
|
||||
vimPlugins.coc-clangd
|
||||
vimPlugins.coc-cmake
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
12
common/home/neovim/langs/default.nix
Normal file
12
common/home/neovim/langs/default.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./bash.nix
|
||||
./clang.nix
|
||||
./java.nix
|
||||
./lua.nix
|
||||
./markdown.nix
|
||||
./nix.nix
|
||||
./python.nix
|
||||
./web.nix
|
||||
];
|
||||
}
|
62
common/home/neovim/langs/java.nix
Normal file
62
common/home/neovim/langs/java.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (pkgs) vimPlugins;
|
||||
inherit (config.vars) neovimIde;
|
||||
|
||||
javaSdk = pkgs.temurin-bin-17;
|
||||
javaPkgs = with pkgs; [gradle maven];
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
home.packages = javaPkgs;
|
||||
|
||||
xdg.dataFile.".gradle/gradle.properties".text = ''
|
||||
org.gradle.java.home = ${javaSdk}
|
||||
'';
|
||||
|
||||
programs = {
|
||||
java = {
|
||||
enable = true;
|
||||
package = javaSdk;
|
||||
};
|
||||
|
||||
neovim = {
|
||||
extraPackages = javaPkgs;
|
||||
|
||||
extraLuaConfig =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = 'java',
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
'';
|
||||
|
||||
coc.settings.java = {
|
||||
maven.downloadSources = true;
|
||||
eclipse.downloadSources = true;
|
||||
|
||||
format.settings.url = "eclipse-formatter.xml";
|
||||
|
||||
jdt.ls = {
|
||||
java.home = "${javaSdk}";
|
||||
statusIcons = {
|
||||
"busy" = "Busy";
|
||||
"ready" = "OK";
|
||||
"warning" = "Warning";
|
||||
"error" = "Error";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
plugins = [
|
||||
vimPlugins.coc-java
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
39
common/home/neovim/langs/lua.nix
Normal file
39
common/home/neovim/langs/lua.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) neovimIde;
|
||||
inherit (pkgs) vimPlugins;
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
coc.settings = {
|
||||
Lua = {
|
||||
misc.parameters = [
|
||||
"--metapath"
|
||||
"~/.cache/sumneko_lua/meta"
|
||||
"--logpath"
|
||||
"~/.cache/sumneko_lua/log"
|
||||
];
|
||||
workspace.library = [
|
||||
"$\{3rd\}/luv/library"
|
||||
];
|
||||
};
|
||||
sumneko-lua = {
|
||||
serverDir = "${pkgs.lua-language-server}/share/lua-language-server";
|
||||
enableNvimLuaDev = true;
|
||||
};
|
||||
};
|
||||
|
||||
plugins = [
|
||||
vimPlugins.coc-sumneko-lua
|
||||
vimPlugins.neodev-nvim
|
||||
|
||||
vimPlugins.coc-vimlsp
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
48
common/home/neovim/langs/markdown.nix
Normal file
48
common/home/neovim/langs/markdown.nix
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
vimplugin-easytables-src,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) neovimIde;
|
||||
inherit (pkgs) vimPlugins;
|
||||
|
||||
buildPlugin = pname: src:
|
||||
pkgs.vimUtils.buildVimPlugin {
|
||||
inherit pname src;
|
||||
version = src.shortRev;
|
||||
};
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
coc.settings = {
|
||||
markdownlint.config = {
|
||||
no-trailing-spaces = true;
|
||||
no-multiple-blanks = false;
|
||||
no-duplicate-heading = false;
|
||||
line-length = {
|
||||
tables = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
plugins = [
|
||||
vimPlugins.markdown-preview-nvim
|
||||
vimPlugins.coc-markdownlint
|
||||
{
|
||||
plugin = buildPlugin "easytables-nvim" vimplugin-easytables-src;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require('easytables').setup();
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
61
common/home/neovim/langs/nix.nix
Normal file
61
common/home/neovim/langs/nix.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
nixd,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) hostName mainUser neovimIde;
|
||||
inherit (lib) hasPrefix removePrefix;
|
||||
|
||||
nixdPkg = nixd.packages.${pkgs.system}.default;
|
||||
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
flakeDir = "${removePrefix "/home/${mainUser}/" flakeEnv}";
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
assertions = [
|
||||
{
|
||||
assertion = neovimIde && hasPrefix "/home/${mainUser}/" flakeEnv || !neovimIde;
|
||||
message = ''
|
||||
Your $FLAKE environment variable needs to point to a directory in
|
||||
the main users' home to use the neovim module.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
alejandra
|
||||
|
||||
# FIXME: set nixd to use alejandra
|
||||
(writeShellApplication {
|
||||
name = "nixpkgs-fmt";
|
||||
runtimeInputs = [alejandra];
|
||||
text = "alejandra \"$@\"";
|
||||
})
|
||||
];
|
||||
|
||||
xdg.dataFile."${flakeDir}/.nixd.json".text = builtins.toJSON {
|
||||
nixpkgs = {
|
||||
expr = "import (builtins.getFlake \"${flakeDir}\").inputs.nixpkgs {}";
|
||||
};
|
||||
options.nixos = {
|
||||
expr = "(builtins.getFlake \"${flakeDir}\").nixosConfigurations.${hostName}.options";
|
||||
};
|
||||
};
|
||||
|
||||
programs = {
|
||||
neovim = {
|
||||
extraPackages = [
|
||||
nixdPkg
|
||||
];
|
||||
|
||||
coc.settings.languageserver = {
|
||||
nix = {
|
||||
command = "nixd";
|
||||
filetypes = ["nix"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
24
common/home/neovim/langs/python.nix
Normal file
24
common/home/neovim/langs/python.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) neovimIde;
|
||||
inherit (pkgs) vimPlugins;
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
withPython3 = true;
|
||||
|
||||
extraPython3Packages = ps: [
|
||||
ps.pylint
|
||||
];
|
||||
|
||||
plugins = [
|
||||
vimPlugins.coc-pyright
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
73
common/home/neovim/langs/web.nix
Normal file
73
common/home/neovim/langs/web.nix
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
coc-stylelintplus,
|
||||
...
|
||||
}: let
|
||||
inherit (config.vars) neovimIde;
|
||||
inherit (pkgs) vimPlugins;
|
||||
|
||||
coc-stylelintplus-flake = coc-stylelintplus.packages.${pkgs.system}.default;
|
||||
in
|
||||
lib.mkIf neovimIde {
|
||||
programs = {
|
||||
neovim = {
|
||||
withNodeJs = true;
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
nodejs_latest
|
||||
nodePackages.npm
|
||||
nodePackages.neovim
|
||||
];
|
||||
|
||||
extraLuaConfig =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { 'javascript' , 'typescript'},
|
||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = 'html',
|
||||
command = 'setlocal ts=2 sw=2 expandtab',
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = 'scss',
|
||||
command = 'setl iskeyword+=@-@',
|
||||
});
|
||||
'';
|
||||
|
||||
coc.settings = {
|
||||
# ESLint
|
||||
eslint = {
|
||||
format.enable = true;
|
||||
autoFixOnSave = true;
|
||||
};
|
||||
|
||||
# Stylelint
|
||||
stylelintplus = {
|
||||
enable = true;
|
||||
cssInJs = true;
|
||||
autoFixOnSave = true;
|
||||
autoFixOnFormat = true;
|
||||
};
|
||||
css.validate = false;
|
||||
less.validate = false;
|
||||
scss.validate = false;
|
||||
wxss.validate = false;
|
||||
};
|
||||
|
||||
plugins = [
|
||||
vimPlugins.coc-css
|
||||
vimPlugins.coc-eslint
|
||||
coc-stylelintplus-flake
|
||||
vimPlugins.coc-tsserver
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue