added neovim config
This commit is contained in:
parent
70739269cb
commit
bfed0f0842
125
home.nix
125
home.nix
|
@ -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
|
||||
# manage.
|
||||
|
@ -38,6 +121,7 @@
|
|||
ripgrep
|
||||
tmate
|
||||
comic-mono
|
||||
comfortaa
|
||||
btop
|
||||
firefox
|
||||
apostrophe
|
||||
|
@ -46,7 +130,6 @@
|
|||
mpv
|
||||
wl-clipboard
|
||||
adw-gtk3
|
||||
# some bullshit to get gnome apps to install withotu a prefix
|
||||
] ++ ( with pkgs.gnome; [
|
||||
gnome-boxes
|
||||
gnome-tweaks
|
||||
|
@ -75,7 +158,6 @@
|
|||
|
||||
home.sessionVariables = {
|
||||
# system configuration
|
||||
# EDITOR = "nvim";
|
||||
VISUAL = "neovide --nofork";
|
||||
NEOVIDE_MULTIGRID = 1;
|
||||
|
||||
|
@ -118,6 +200,43 @@
|
|||
vimdiffAlias = 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 = {
|
||||
enable = true;
|
||||
};
|
||||
|
|
84
modules/neovim-config.nix
Normal file
84
modules/neovim-config.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue