2022-12-18 15:15:15 +00:00
|
|
|
with builtins;
|
|
|
|
|
2023-02-01 01:07:21 +00:00
|
|
|
{pkgs, lib}:
|
2022-12-18 15:15:15 +00:00
|
|
|
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)
|
|
|
|
);
|
2023-12-18 16:06:05 +00:00
|
|
|
mkDigraph = {keys, code}: "dig " + keys + " " + (toString code) + "\n";
|
|
|
|
mkDigraphs = dgs: (concatStringsSep "" (map mkDigraph dgs));
|
2022-12-18 15:15:15 +00:00
|
|
|
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);
|
2023-12-18 16:06:05 +00:00
|
|
|
mkConfig = { settings?{}, mappings?[], digraphs?[], runtimes?[], extra?"" }:
|
2022-12-18 15:15:15 +00:00
|
|
|
mkVimSections [
|
|
|
|
{"ADDITIONAL RUNTIME DIRS" = mkRuntimes runtimes;}
|
|
|
|
{"SETTINGS" = mkSettings settings;}
|
2023-12-18 16:06:05 +00:00
|
|
|
{"DIGRAPHS" = mkDigraphs digraphs;}
|
2022-12-18 15:15:15 +00:00
|
|
|
{"KEY BINGINGS" = mkMappings mappings;}
|
|
|
|
{"MANUAL SETTINGS" = extra;}
|
|
|
|
];
|
2023-02-01 01:07:21 +00:00
|
|
|
|
|
|
|
# Via https://gist.github.com/nat-418/d76586da7a5d113ab90578ed56069509
|
2023-12-23 00:37:27 +00:00
|
|
|
fromGitHub = ref: repo: pkgs.vimUtils.buildVimPlugin {
|
2023-02-01 01:07:21 +00:00
|
|
|
pname = "${lib.strings.sanitizeDerivationName repo}";
|
|
|
|
version = ref;
|
|
|
|
src = builtins.fetchGit {
|
|
|
|
url = "https://github.com/${repo}.git";
|
|
|
|
ref = ref;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-18 15:15:15 +00:00
|
|
|
in
|
2023-02-01 01:07:21 +00:00
|
|
|
{
|
2022-12-18 15:15:15 +00:00
|
|
|
enable = true;
|
|
|
|
plugins = with pkgs.vimPlugins; [
|
|
|
|
editorconfig-nvim
|
|
|
|
vim-airline
|
|
|
|
vim-airline-themes
|
|
|
|
lsp_signature-nvim
|
|
|
|
nvim-colorizer-lua
|
|
|
|
nnn-vim
|
|
|
|
nvim-surround
|
|
|
|
hop-nvim
|
|
|
|
nvim-treesitter.withAllGrammars
|
|
|
|
nvim-ts-rainbow
|
|
|
|
nvim-lspconfig
|
2023-02-01 01:07:21 +00:00
|
|
|
(fromGitHub "HEAD" "whonore/Coqtail")
|
2022-12-18 15:15:15 +00:00
|
|
|
];
|
|
|
|
extraConfig = mkConfig {
|
|
|
|
settings = {
|
|
|
|
number = true;
|
|
|
|
expandtab = false;
|
|
|
|
linebreak = true;
|
|
|
|
display = "lastline";
|
|
|
|
comments = "s1:/*,mb:*,ex:*/,:///\\ #,:///,://!,://,b:#,:%,:XCOMM,n:>,b:-,b:*";
|
|
|
|
tgc = true;
|
|
|
|
tw = 90;
|
|
|
|
foldmethod = "expr";
|
|
|
|
foldexpr = "nvim_treesitter#foldexpr()";
|
|
|
|
foldminlines = 10;
|
|
|
|
foldnestmax = 2;
|
|
|
|
};
|
2023-12-18 16:06:05 +00:00
|
|
|
digraphs = [
|
|
|
|
{ # Append
|
|
|
|
keys = "<>";
|
|
|
|
code = 8853;
|
|
|
|
}
|
|
|
|
{ # Multi Map
|
|
|
|
keys = "-o";
|
|
|
|
code = 8888;
|
|
|
|
}
|
|
|
|
{ # Degree Symbol
|
|
|
|
keys = "'o";
|
|
|
|
code = 176;
|
|
|
|
}
|
|
|
|
{ # Ring Operator
|
|
|
|
keys = ".o";
|
|
|
|
code = 8728;
|
|
|
|
}
|
|
|
|
{ # Integers
|
|
|
|
keys = "ZZ";
|
|
|
|
code = 8484;
|
|
|
|
}
|
|
|
|
{ # Naturals
|
|
|
|
keys = "NN";
|
|
|
|
code = 8469;
|
|
|
|
}
|
|
|
|
{ # Reals
|
|
|
|
keys = "RR";
|
|
|
|
code = 8477;
|
|
|
|
}
|
|
|
|
{ # Rationals
|
|
|
|
keys = "QQ";
|
|
|
|
code = 8474;
|
|
|
|
}
|
|
|
|
];
|
2022-12-18 15:15:15 +00:00
|
|
|
mappings = [
|
2023-12-18 16:06:19 +00:00
|
|
|
{ # New tab
|
2022-12-18 15:15:15 +00:00
|
|
|
mode = "";
|
|
|
|
binding = "<C-t>";
|
|
|
|
command = "<Cmd>:tab split<CR>";
|
|
|
|
}
|
2023-12-18 16:06:19 +00:00
|
|
|
{ # File picker
|
2022-12-18 15:15:15 +00:00
|
|
|
mode = "n";
|
|
|
|
binding = "<C-n>";
|
|
|
|
command = "<cmd>call nnn#pick(expand('%:p:h'))<CR>";
|
|
|
|
}
|
2023-12-18 16:06:19 +00:00
|
|
|
{ # Jump
|
2022-12-18 15:15:15 +00:00
|
|
|
mode = "n";
|
|
|
|
binding = "<C-h>";
|
|
|
|
command = "<cmd>HopWord<CR>";
|
|
|
|
}
|
2023-12-18 16:06:19 +00:00
|
|
|
{ # Jump by characters
|
2022-12-18 15:15:15 +00:00
|
|
|
mode = "n";
|
2023-12-18 16:06:19 +00:00
|
|
|
binding = "<C-o>";
|
2022-12-18 15:15:15 +00:00
|
|
|
command = "<cmd>HopChar2<CR>";
|
|
|
|
}
|
2023-12-18 16:06:19 +00:00
|
|
|
{ # Clear search
|
|
|
|
mode = "";
|
|
|
|
binding = "<C-l>";
|
|
|
|
command = "<cmd>noh<CR>";
|
|
|
|
}
|
2022-12-18 15:15:15 +00:00
|
|
|
{
|
|
|
|
mode = "i";
|
|
|
|
binding = "<Tab>";
|
|
|
|
command = "coc#pum#visible() ? coc#pum#next(1) : CheckBackspace() ? \"\\<Tab>\" : coc#refresh()";
|
|
|
|
silent = true;
|
|
|
|
expr = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "i";
|
|
|
|
binding = "<S-Tab>";
|
|
|
|
command = "coc#pum#visible() ? coc#pum#prev(1) : \"\\<C-h>\"";
|
|
|
|
expr = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "<C-Space>";
|
|
|
|
command = "coc#refresh()";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "[g";
|
|
|
|
command = "<Plug>(coc-diagnostic-prev)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "]g";
|
|
|
|
command = "<Plug>(coc-diagnostic-next)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "gd";
|
|
|
|
command = "<Plug>(coc-definition)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "gy";
|
|
|
|
command = "<Plug>(coc-type-definition)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "gi";
|
|
|
|
command = "<Plug>(coc-implementation)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "gr";
|
|
|
|
command = "<Plug>(coc-references)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "K";
|
|
|
|
command = ":call ShowDocumentation()<CR>";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "...";
|
|
|
|
command = "<Plug>(coc-codeaction-cursor)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "<Space>rn";
|
|
|
|
command = "<Plug>(coc-rename)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
binding = "<Space>cl";
|
|
|
|
command = "<Plug>(coc-codelens-action)";
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
runtimes = [neovim/laserwave];
|
|
|
|
extra = builtins.readFile neovim/init.vim;
|
|
|
|
};
|
|
|
|
coc.enable = true;
|
|
|
|
coc.settings = {
|
2023-02-09 19:22:55 +00:00
|
|
|
"diagnostic-languageserver.filetypes" = {
|
|
|
|
python = "mypy";
|
|
|
|
};
|
2023-12-18 16:07:19 +00:00
|
|
|
haskell = {
|
|
|
|
command = "haskell-language-server-wrapper";
|
|
|
|
args = ["--lsp"];
|
|
|
|
rootPatterns = ["*.cabal" "stack.yaml" "cabal.project" "package.yaml" "hie.yaml"];
|
|
|
|
filetypes = ["hs" "lhs" "haskell" "lhaskell"];
|
|
|
|
};
|
2022-12-18 15:15:15 +00:00
|
|
|
};
|
|
|
|
}
|