home/nvim: get rid of the stupid _ semicolon thing
This commit is contained in:
parent
0cc3ec10b3
commit
5bfcdf6e65
|
@ -25,27 +25,6 @@
|
||||||
inherit (notlua-nvim.keywords) REQ REQ';
|
inherit (notlua-nvim.keywords) REQ REQ';
|
||||||
in let
|
in let
|
||||||
vimg = name: PROP vim.g name;
|
vimg = name: PROP vim.g name;
|
||||||
# _ is basically semicolon
|
|
||||||
_ = { __IS_SEPARATOR = true; };
|
|
||||||
splitList = sep: list:
|
|
||||||
let
|
|
||||||
ivPairs = lib.imap0 (i: x: { inherit i x; }) list;
|
|
||||||
is' = map ({ i, ... }: i) (builtins.filter ({ x, ... }: sep == x) ivPairs);
|
|
||||||
is = [ 0 ] ++ (map (x: x + 1) is');
|
|
||||||
ie = is' ++ [ (builtins.length list) ];
|
|
||||||
se = lib.zipLists is ie;
|
|
||||||
in
|
|
||||||
map ({ fst, snd }: lib.sublist fst (snd - fst) list) se;
|
|
||||||
# this transforms [ a b _ c _ d _ e f g ] into [ (a b) c d (RETURN (e f g)) ]
|
|
||||||
L = args:
|
|
||||||
let
|
|
||||||
spl = splitList _ args;
|
|
||||||
body = lib.init spl;
|
|
||||||
ret = lib.last spl;
|
|
||||||
in
|
|
||||||
(map
|
|
||||||
(list: builtins.foldl' lib.id (builtins.head list) (builtins.tail list))
|
|
||||||
body) ++ (if ret == [] then [] else [(APPLY RETURN ret)]);
|
|
||||||
keymapSetSingle = opts@{
|
keymapSetSingle = opts@{
|
||||||
mode,
|
mode,
|
||||||
lhs,
|
lhs,
|
||||||
|
@ -84,7 +63,6 @@
|
||||||
|
|
||||||
which-key = REQ "which-key";
|
which-key = REQ "which-key";
|
||||||
luasnip = REQ "luasnip";
|
luasnip = REQ "luasnip";
|
||||||
compile' = name: stmts: compile name (L stmts);
|
|
||||||
in {
|
in {
|
||||||
enable = true;
|
enable = true;
|
||||||
defaultEditor = true;
|
defaultEditor = true;
|
||||||
|
@ -114,40 +92,40 @@
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
vimdiffAlias = true;
|
vimdiffAlias = true;
|
||||||
|
|
||||||
extraLuaConfig = (compile' "main" [
|
extraLuaConfig = compile "main" [
|
||||||
kmSetNs {
|
(kmSetNs {
|
||||||
"<C-X>" = {
|
"<C-X>" = {
|
||||||
rhs = DEFUN (vim.fn.system [ "chmod" "+x" (vim.fn.expand "%") ]);
|
rhs = DEFUN (vim.fn.system [ "chmod" "+x" (vim.fn.expand "%") ]);
|
||||||
desc = "chmod +x %";
|
desc = "chmod +x %";
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
SET (vimg "vimsyn_embed") "l" _
|
(SET (vimg "vimsyn_embed") "l")
|
||||||
LET (vim.api.nvim_create_augroup "nvimrc" { clear = true; }) (group:
|
(LET (vim.api.nvim_create_augroup "nvimrc" { clear = true; }) (group:
|
||||||
lib.mapAttrsToList (k: v: vim.api.nvim_create_autocmd k { inherit group; callback = v; }) {
|
lib.mapAttrsToList (k: v: vim.api.nvim_create_autocmd k { inherit group; callback = v; }) {
|
||||||
BufReadPre = DEFUN (SET vim.o.foldmethod "syntax");
|
BufReadPre = DEFUN (SET vim.o.foldmethod "syntax");
|
||||||
BufEnter = { buf, ... }:
|
BufEnter = { buf, ... }:
|
||||||
LET (vim.filetype.match { inherit buf; }) (filetype: L [
|
LET (vim.filetype.match { inherit buf; }) (filetype: [
|
||||||
IF (APPLY OR (map (EQ filetype) [ "gitcommit" "markdown" ])) (
|
(IF (APPLY OR (map (EQ filetype) [ "gitcommit" "markdown" ])) (
|
||||||
LET vim.o.colorcolumn (old_colorcolumn: L [
|
LET vim.o.colorcolumn (old_colorcolumn: [
|
||||||
SET vim.o.colorcolumn "73" _
|
(SET vim.o.colorcolumn "73")
|
||||||
vim.api.nvim_create_autocmd "BufLeave" {
|
(vim.api.nvim_create_autocmd "BufLeave" {
|
||||||
buffer = buf;
|
buffer = buf;
|
||||||
callback = DEFUN (L [
|
callback = DEFUN [
|
||||||
SET vim.o.colorcolumn old_colorcolumn _
|
(SET vim.o.colorcolumn old_colorcolumn)
|
||||||
# return true = delete autocommand
|
# return true = delete autocommand
|
||||||
true
|
(RETURN true)
|
||||||
]);
|
];
|
||||||
} _
|
})
|
||||||
])
|
])
|
||||||
) _
|
))
|
||||||
IF (EQ filetype "markdown") (
|
(IF (EQ filetype "markdown") (
|
||||||
(SET (IDX vim.bo buf).textwidth 72)
|
(SET (IDX vim.bo buf).textwidth 72)
|
||||||
) _
|
))
|
||||||
]);
|
]);
|
||||||
BufWinEnter = { buf, ... }:
|
BufWinEnter = { buf, ... }:
|
||||||
LET (vim.filetype.match { inherit buf; }) (filetype: L [
|
LET (vim.filetype.match { inherit buf; }) (filetype: [
|
||||||
CALL (PROP vim.cmd "folddoc") "foldopen!" _
|
(CALL (PROP vim.cmd "folddoc") "foldopen!")
|
||||||
IF (EQ filetype "gitcommit") (
|
(IF (EQ filetype "gitcommit") (
|
||||||
vim.cmd {
|
vim.cmd {
|
||||||
cmd = "normal"; bang = true;
|
cmd = "normal"; bang = true;
|
||||||
args = [ "gg" ];
|
args = [ "gg" ];
|
||||||
|
@ -171,11 +149,11 @@
|
||||||
cmd = "normal"; bang = true;
|
cmd = "normal"; bang = true;
|
||||||
args = [ "gg" ];
|
args = [ "gg" ];
|
||||||
})
|
})
|
||||||
)) _
|
)))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
) _
|
))
|
||||||
]);
|
];
|
||||||
plugins = let ps = pkgs.vimPlugins; in map (x: if x?config && x?plugin then { type = "lua"; } // x else x) [
|
plugins = let ps = pkgs.vimPlugins; in map (x: if x?config && x?plugin then { type = "lua"; } // x else x) [
|
||||||
ps.vim-svelte
|
ps.vim-svelte
|
||||||
# vim-nix isn't necessary for syntax highlighting, but it improves overall editing experience
|
# vim-nix isn't necessary for syntax highlighting, but it improves overall editing experience
|
||||||
|
@ -190,8 +168,8 @@
|
||||||
sha256 = "sha256-X2IgIjO5NNq7vJdl09hBY1TFqHlsfF1xfllKr4osILI=";
|
sha256 = "sha256-X2IgIjO5NNq7vJdl09hBY1TFqHlsfF1xfllKr4osILI=";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = compile' "vscode_nvim" [
|
config = compile "vscode_nvim" [
|
||||||
(REQ "vscode").setup {
|
((REQ "vscode").setup {
|
||||||
transparent = true;
|
transparent = true;
|
||||||
color_overrides = {
|
color_overrides = {
|
||||||
vscGray = "#745b5f";
|
vscGray = "#745b5f";
|
||||||
|
@ -208,25 +186,25 @@
|
||||||
vscYellow = "#${config.colors.yellow}";
|
vscYellow = "#${config.colors.yellow}";
|
||||||
vscPink = "#cf83c4";
|
vscPink = "#cf83c4";
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
vim.api.nvim_set_hl 0 "NormalFloat" {
|
(vim.api.nvim_set_hl 0 "NormalFloat" {
|
||||||
bg = "NONE";
|
bg = "NONE";
|
||||||
} _
|
})
|
||||||
]; }
|
]; }
|
||||||
{ plugin = ps.nvim-web-devicons;
|
{ plugin = ps.nvim-web-devicons;
|
||||||
config = compile "nvim_web_devicons" ((REQ "nvim-web-devicons").setup { }); }
|
config = compile "nvim_web_devicons" ((REQ "nvim-web-devicons").setup { }); }
|
||||||
{ plugin = ps.nvim-tree-lua;
|
{ plugin = ps.nvim-tree-lua;
|
||||||
config = compile "nvim_tree_lua" (LET (REQ "nvim-tree") (REQ "nvim-tree.api") (nvim-tree: nvim-tree-api: L [
|
config = compile "nvim_tree_lua" (LET (REQ "nvim-tree") (REQ "nvim-tree.api") (nvim-tree: nvim-tree-api: [
|
||||||
SET (vimg "loaded_netrw") 1 _
|
(SET (vimg "loaded_netrw") 1)
|
||||||
SET (vimg "loaded_netrwPlugin") 1 _
|
(SET (vimg "loaded_netrwPlugin") 1)
|
||||||
SET vim.o.termguicolors true _
|
(SET vim.o.termguicolors true)
|
||||||
nvim-tree.setup { } _ # :help nvim-tree-setup
|
(nvim-tree.setup { }) # :help nvim-tree-setup
|
||||||
kmSetNs {
|
(kmSetNs {
|
||||||
"<C-N>" = {
|
"<C-N>" = {
|
||||||
rhs = nvim-tree-api.tree.toggle;
|
rhs = nvim-tree-api.tree.toggle;
|
||||||
desc = "Toggle NvimTree";
|
desc = "Toggle NvimTree";
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
])); }
|
])); }
|
||||||
ps.vim-sleuth
|
ps.vim-sleuth
|
||||||
ps.luasnip
|
ps.luasnip
|
||||||
|
@ -259,9 +237,9 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
formatting = {
|
formatting = {
|
||||||
format = entry: vim_item: let kind = PROP vim_item "kind"; in L [
|
format = entry: vim_item: let kind = PROP vim_item "kind"; in [
|
||||||
SET kind (string.format "%s %s" (IDX lspkind kind) kind) _
|
(SET kind (string.format "%s %s" (IDX lspkind kind) kind))
|
||||||
vim_item
|
(RETURN vim_item)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
mapping = {
|
mapping = {
|
||||||
|
@ -311,28 +289,28 @@
|
||||||
config = compile "nvim_autopairs" (LET
|
config = compile "nvim_autopairs" (LET
|
||||||
(REQ "cmp") (REQ "nvim-autopairs.completion.cmp") (REQ "nvim-autopairs")
|
(REQ "cmp") (REQ "nvim-autopairs.completion.cmp") (REQ "nvim-autopairs")
|
||||||
(cmp: cmp-autopairs: nvim-autopairs:
|
(cmp: cmp-autopairs: nvim-autopairs:
|
||||||
L [
|
[
|
||||||
nvim-autopairs.setup {
|
(nvim-autopairs.setup {
|
||||||
disable_filetype = [ "TelescopePrompt" "vim" ];
|
disable_filetype = [ "TelescopePrompt" "vim" ];
|
||||||
} _
|
})
|
||||||
cmp.event.on cmp.event "confirm_done" (cmp-autopairs.on_confirm_done { }) _
|
(cmp.event.on cmp.event "confirm_done" (cmp-autopairs.on_confirm_done { }))
|
||||||
])); }
|
])); }
|
||||||
{ plugin = ps.comment-nvim;
|
{ plugin = ps.comment-nvim;
|
||||||
config = compile' "comment_nvim" [
|
config = compile "comment_nvim" [
|
||||||
(REQ "Comment").setup { } _
|
((REQ "Comment").setup { })
|
||||||
kmSetNs {
|
(kmSetNs {
|
||||||
"<space>/" = {
|
"<space>/" = {
|
||||||
# metatables......
|
# metatables......
|
||||||
rhs = REQ' (PROP (require "Comment.api") "toggle.linewise.current");
|
rhs = REQ' (PROP (require "Comment.api") "toggle.linewise.current");
|
||||||
desc = "Comment current line";
|
desc = "Comment current line";
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
kmSetVs {
|
(kmSetVs {
|
||||||
"<space>/" = {
|
"<space>/" = {
|
||||||
rhs = "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>";
|
rhs = "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>";
|
||||||
desc = "Comment selection";
|
desc = "Comment selection";
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
]; }
|
]; }
|
||||||
{ plugin = ps.nvim-lspconfig;
|
{ plugin = ps.nvim-lspconfig;
|
||||||
config = compile "nvim_lspconfig" (
|
config = compile "nvim_lspconfig" (
|
||||||
|
@ -341,9 +319,9 @@
|
||||||
(REQ "lspconfig.server_configurations.${name}")
|
(REQ "lspconfig.server_configurations.${name}")
|
||||||
# metatables, son! they harden in response to physical trauma
|
# metatables, son! they harden in response to physical trauma
|
||||||
(REQ' (PROP (require "lspconfig") name));
|
(REQ' (PROP (require "lspconfig") name));
|
||||||
in L [
|
in [
|
||||||
# See `:help vim.diagnostic.*` for documentation on any of the below functions
|
# See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
kmSetNs {
|
(kmSetNs {
|
||||||
"<space>e" = {
|
"<space>e" = {
|
||||||
rhs = vim.diagnostic.open_float;
|
rhs = vim.diagnostic.open_float;
|
||||||
desc = "Show diagnostics in a floating window.";
|
desc = "Show diagnostics in a floating window.";
|
||||||
|
@ -360,19 +338,17 @@
|
||||||
rhs = vim.diagnostic.setloclist;
|
rhs = vim.diagnostic.setloclist;
|
||||||
desc = "Add buffer diagnostics to the location list.";
|
desc = "Add buffer diagnostics to the location list.";
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
LET
|
(LET
|
||||||
# LET on_attach
|
# LET on_attach
|
||||||
(client: bufnr: L [
|
(client: bufnr: [
|
||||||
SET (IDX vim.bo bufnr).omnifunc "v:lua.vim.lsp.omnifunc" _
|
(SET (IDX vim.bo bufnr).omnifunc "v:lua.vim.lsp.omnifunc")
|
||||||
# Mappings.
|
# Mappings.
|
||||||
# See `:help vim.lsp.*` for documentation on any of the below functions
|
# See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
keymapSetNs {
|
(keymapSetNs {
|
||||||
buffer = bufnr;
|
buffer = bufnr;
|
||||||
keys = {
|
keys = {
|
||||||
"gD" = {
|
"gD" = { rhs = vim.lsp.buf.declaration; desc = "Jumps to the declaration of the symbol under the cursor."; };
|
||||||
rhs = vim.lsp.buf.declaration;
|
|
||||||
desc = "Jumps to the declaration of the symbol under the cursor."; };
|
|
||||||
"gd" = {
|
"gd" = {
|
||||||
rhs = vim.lsp.buf.definition;
|
rhs = vim.lsp.buf.definition;
|
||||||
desc = "Jumps to the definition of the symbol under the cursor."; };
|
desc = "Jumps to the definition of the symbol under the cursor."; };
|
||||||
|
@ -410,7 +386,7 @@
|
||||||
rhs = DEFUN (vim.lsp.buf.format { async = true; });
|
rhs = DEFUN (vim.lsp.buf.format { async = true; });
|
||||||
desc = "Formats a buffer."; };
|
desc = "Formats a buffer."; };
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
])
|
])
|
||||||
# LET rust_settings
|
# LET rust_settings
|
||||||
{ rust-analyzer = {
|
{ rust-analyzer = {
|
||||||
|
@ -428,29 +404,29 @@
|
||||||
(on_attach: rust_settings: capabilities:
|
(on_attach: rust_settings: capabilities:
|
||||||
LETREC
|
LETREC
|
||||||
# LETREC on_attach_rust
|
# LETREC on_attach_rust
|
||||||
(on_attach_rust: client: bufnr: L [
|
(on_attach_rust: client: bufnr: [
|
||||||
vim.api.nvim_buf_create_user_command bufnr "RustAndroid" (opts: L [
|
(vim.api.nvim_buf_create_user_command bufnr "RustAndroid" (opts: [
|
||||||
vim.lsp.set_log_level "debug" _
|
(vim.lsp.set_log_level "debug")
|
||||||
(lsp "rust_analyzer").setup {
|
((lsp "rust_analyzer").setup {
|
||||||
on_attach = on_attach_rust;
|
on_attach = on_attach_rust;
|
||||||
inherit capabilities;
|
inherit capabilities;
|
||||||
settings = vim.tbl_deep_extend
|
settings = vim.tbl_deep_extend
|
||||||
"keep"
|
"keep"
|
||||||
config.rustAnalyzerAndroidSettings
|
config.rustAnalyzerAndroidSettings
|
||||||
rust_settings;
|
rust_settings;
|
||||||
} _
|
})
|
||||||
]) {} _
|
]) {})
|
||||||
on_attach client bufnr _
|
(on_attach client bufnr)
|
||||||
])
|
])
|
||||||
# BEGIN
|
# BEGIN
|
||||||
(let setupLsp = name: args: (lsp name).setup ({
|
(let setupLsp = name: args: (lsp name).setup ({
|
||||||
inherit on_attach capabilities;
|
inherit on_attach capabilities;
|
||||||
settings = { };
|
settings = { };
|
||||||
} // args);
|
} // args);
|
||||||
in on_attach_rust: L [
|
in on_attach_rust: [
|
||||||
# vim.lsp.set_log_level "debug" _
|
# (vim.lsp.set_log_level "debug")
|
||||||
# see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
# see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||||
lib.mapAttrsToList setupLsp {
|
(lib.mapAttrsToList setupLsp {
|
||||||
bashls = { };
|
bashls = { };
|
||||||
clangd = { };
|
clangd = { };
|
||||||
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
|
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
|
||||||
|
@ -471,15 +447,15 @@
|
||||||
on_attach = on_attach_rust;
|
on_attach = on_attach_rust;
|
||||||
settings = rust_settings;
|
settings = rust_settings;
|
||||||
};
|
};
|
||||||
} _
|
})
|
||||||
]) # END
|
]) # END
|
||||||
) _ # END
|
)) # END
|
||||||
]); }
|
]); }
|
||||||
{ plugin = ps.which-key-nvim;
|
{ plugin = ps.which-key-nvim;
|
||||||
config = compile' "which_key_nvim" [
|
config = compile "which_key_nvim" [
|
||||||
SET vim.o.timeout true _
|
(SET vim.o.timeout true)
|
||||||
SET vim.o.timeoutlen 500 _
|
(SET vim.o.timeoutlen 500)
|
||||||
which-key.setup { } _
|
(which-key.setup { })
|
||||||
]; }
|
]; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue