added neovim config

This commit is contained in:
Bit Borealis 2023-07-24 08:45:43 +00:00
parent 70739269cb
commit bfed0f0842
Signed by: theotheroracle
GPG key ID: 2D816A2DCA6E5649
2 changed files with 206 additions and 3 deletions

125
home.nix
View file

@ -1,5 +1,88 @@
{ config, pkgs, ... }: { config, pkgs, lib, ... }: with builtins;
let
mkSettings = s:
concatStringsSep
"\n"
(attrValues
(mapAttrs
(k: v:
if typeOf v == "bool" then
if v then "set ${k}" else "set no${k}"
else
"set ${k}=${toString v}")
s
)
);
boolToString = b: if b then "true" else "false";
toLuaTable = as:
"{" +
( concatStringsSep
", "
( filter
(attr: !isNull attr)
( attrValues
( mapAttrs
(k: v: if v then "${k}=true" else null)
as
)
)
)
) +
"}";
mkMapping = {
mode,
binding,
command,
nowait?false,
silent?false,
unique?false,
expr?false
}:
"vim.api.nvim_set_keymap(${toJSON mode}, ${toJSON binding}, ${toJSON command}, ${toLuaTable {inherit nowait silent unique expr;}})";
mkMappings =
m:
"lua << END-OF-KEYBINDS\n" +
(concatStringsSep "\n" (map mkMapping m)) +
"\nEND-OF-KEYBINDS";
mkRuntimes = rs:
if rs == [] then "" else
"set runtimepath+=" +
( concatStringsSep
","
(map (rt: "${rt}") rs)
);
mkVimHeader = h: "\"\"\"\"\"\"\"\" ${h} \"\"\"\"\"\"\"\"\"";
mkVimSection = section:
(concatStringsSep "\n\n\n"
(filter
(v: !isNull v)
(attrValues
(mapAttrs
(k: v: if "" == v then null else (mkVimHeader k) + "\n" + v)
section
)
)
)
);
mkVimSections = sections: concatStringsSep "\n\n\n" (map mkVimSection sections);
mkConfig = { settings?{}, mappings?[], runtimes?[], extra?"" }:
mkVimSections [
{"ADDITIONAL RUNTIME DIRS" = mkRuntimes runtimes;}
{"SETTINGS" = mkSettings settings;}
{"KEY BINGINGS" = mkMappings mappings;}
{"MANUAL SETTINGS" = extra;}
];
# Via https://gist.github.com/nat-418/d76586da7a5d113ab90578ed56069509
fromGitHub = ref: repo: pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "${lib.strings.sanitizeDerivationName repo}";
version = ref;
src = builtins.fetchGit {
url = "https://github.com/${repo}.git";
ref = ref;
};
};
in
{ {
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
@ -38,6 +121,7 @@
ripgrep ripgrep
tmate tmate
comic-mono comic-mono
comfortaa
btop btop
firefox firefox
apostrophe apostrophe
@ -46,7 +130,6 @@
mpv mpv
wl-clipboard wl-clipboard
adw-gtk3 adw-gtk3
# some bullshit to get gnome apps to install withotu a prefix
] ++ ( with pkgs.gnome; [ ] ++ ( with pkgs.gnome; [
gnome-boxes gnome-boxes
gnome-tweaks gnome-tweaks
@ -75,7 +158,6 @@
home.sessionVariables = { home.sessionVariables = {
# system configuration # system configuration
# EDITOR = "nvim";
VISUAL = "neovide --nofork"; VISUAL = "neovide --nofork";
NEOVIDE_MULTIGRID = 1; NEOVIDE_MULTIGRID = 1;
@ -118,6 +200,43 @@
vimdiffAlias = true; vimdiffAlias = true;
withNodeJs = true; withNodeJs = true;
plugins = with pkgs.vimPlugins; [
editorconfig-nvim
vim-airline
vim-airline-themes
lsp_signature-nvim
nvim-colorizer-lua
nnn-vim
nvim-surround
nvim-treesitter.withAllGrammars
(fromGitHub "HEAD" "hiphish/rainbow-delimiters.nvim")
nvim-lspconfig
];
extraConfig = mkConfig {
settings = {
number = true;
linebreak = true;
showbreak = "+>";
textwidth = 100;
showmatch = true;
hlsearch = true;
smartcase = true;
ignorecase = true;
autoindent = true;
smartindent = true;
smarttab = true;
tabstop = 3;
shiftwidth = 3;
display = "lastline";
formatoptions = "jt";
ruler = true;
cc = 101;
termguicolors = true;
};
};
coc = { coc = {
enable = true; enable = true;
}; };

84
modules/neovim-config.nix Normal file
View file

@ -0,0 +1,84 @@
{
mkSettings = s:
concatStringsSep
"\n"
(attrValues
(mapAttrs
(k: v:
if typeOf v == "bool" then
if v then "set ${k}" else "set no${k}"
else
"set ${k}=${toString v}")
s
)
);
boolToString = b: if b then "true" else "false";
toLuaTable = as:
"{" +
( concatStringsSep
", "
( filter
(attr: !isNull attr)
( attrValues
( mapAttrs
(k: v: if v then "${k}=true" else null)
as
)
)
)
) +
"}";
mkMapping = {
mode,
binding,
command,
nowait?false,
silent?false,
unique?false,
expr?false
}:
"vim.api.nvim_set_keymap(${toJSON mode}, ${toJSON binding}, ${toJSON command}, ${toLuaTable {inherit nowait silent unique expr;}})";
mkMappings =
m:
"lua << END-OF-KEYBINDS\n" +
(concatStringsSep "\n" (map mkMapping m)) +
"\nEND-OF-KEYBINDS";
mkRuntimes = rs:
if rs == [] then "" else
"set runtimepath+=" +
( concatStringsSep
","
(map (rt: "${rt}") rs)
);
mkVimHeader = h: "\"\"\"\"\"\"\"\" ${h} \"\"\"\"\"\"\"\"\"";
mkVimSection = section:
(concatStringsSep "\n\n\n"
(filter
(v: !isNull v)
(attrValues
(mapAttrs
(k: v: if "" == v then null else (mkVimHeader k) + "\n" + v)
section
)
)
)
);
mkVimSections = sections: concatStringsSep "\n\n\n" (map mkVimSection sections);
mkConfig = { settings?{}, mappings?[], runtimes?[], extra?"" }:
mkVimSections [
{"ADDITIONAL RUNTIME DIRS" = mkRuntimes runtimes;}
{"SETTINGS" = mkSettings settings;}
{"KEY BINGINGS" = mkMappings mappings;}
{"MANUAL SETTINGS" = extra;}
];
# Via https://gist.github.com/nat-418/d76586da7a5d113ab90578ed56069509
fromGitHub = ref: repo: pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "${lib.strings.sanitizeDerivationName repo}";
version = ref;
src = builtins.fetchGit {
url = "https://github.com/${repo}.git";
ref = ref;
};
};
}