system/neovim/dev.nix

241 lines
6 KiB
Nix
Raw Normal View History

{ modulesPath, lib, pkgs, ... }:
2024-05-10 02:39:22 +03:00
let
2024-11-24 15:47:42 +03:00
inherit (lib.mod) ctrl localLeader Bs;
inherit (lib.nix2lua) pipe1 require call0 nf var;
2024-05-10 02:39:22 +03:00
in
{
imports = [
2024-11-25 23:29:07 +03:00
"${modulesPath}/profiles/base.nix"
"${modulesPath}/profiles/recommended-plugins.nix"
./keymaps.nix
2024-05-20 23:03:25 +03:00
./snippets.nix
./configs
./plugins
2024-05-10 02:39:22 +03:00
];
2024-05-17 22:26:17 +03:00
vim.opt = {
list = true;
formatoptions = "roqnlj";
2024-05-17 15:28:57 +03:00
};
buffer.filetype = {
2024-06-16 05:35:09 +03:00
text-options = {
pattern = [ "txt" "markdown" "mail" "man" ];
opt = { formatoptions = "roqwnjp"; };
};
};
2024-05-10 02:39:22 +03:00
2024-05-17 22:26:17 +03:00
filetype.detect = {
d2 = "*.d2";
nickel = "*.ncl";
psql = "*.psql";
2024-08-10 06:26:53 +03:00
sql = "*.pgsql";
2024-05-17 22:26:17 +03:00
};
# Enable fast navigation between windows
vim.keymap.set = map (k: { mode = "n"; lhs = ctrl k; rhs = "${ctrl "w"}${k}"; }) [ "h" "l" "j" "k" ];
2024-11-25 23:29:07 +03:00
plugin.nvim-web-devicons.enable = true;
plugin.oil-nvim = {
enable = true;
name = "oil";
setupSettings = {
columns = [ "icon" ];
2024-11-25 23:29:07 +03:00
};
};
2024-11-24 17:15:49 +03:00
plugin.nvim-surround = {
enable = true;
2024-11-25 23:29:07 +03:00
setupSettings = { };
2024-11-24 17:15:49 +03:00
};
plugin.nvim-treesitter-textobjects.enable = false;
2024-11-24 15:47:42 +03:00
plugins.style.nvim-treesitter = {
extraGrammars = {
tree-sitter-d2 = rec {
language = "d2";
version = "1e6d8ca3d85c0031ff010759bb60804dd47b95f2";
src = pkgs.fetchFromGitea {
domain = "git.pleshevski.ru";
owner = "pleshevskiy";
repo = "tree-sitter-d2";
rev = version;
sha256 = "sha256-ld9zlJ7tXl/SyrHJXwPKviDHePbw/jhI9WPT3aNntt8=";
};
2024-05-10 22:26:33 +03:00
};
};
# Source: https://github.com/DariusCorvus/tree-sitter-language-injection.nvim/blob/main/lua/tree-sitter-language-injection/init.lua
extraQueries =
let
lang = "sql";
langMatch = ''^//+[ \t]*${lang}[ \t]*|^/[*]+[ \t]*${lang}[ \t]*[*]+/$'';
javascriptInjection = ''
((comment) @comment .
([ (string(string_fragment) @injection.content)
(template_string(string_fragment) @injection.content)
] @injection.content
)
(#match? @comment "${langMatch}")
(#set! injection.language "${lang}")
)
'';
in
{
javascript.injections = javascriptInjection;
typescript.injections = javascriptInjection;
};
2024-11-24 15:47:42 +03:00
settings = {
incremental_selection = {
enable = true;
keymaps = {
init_selection = ctrl "s";
node_incremental = ctrl "s";
scope_incremental = "grs";
node_decremental = Bs;
};
};
textobjects =
let
inner = v: "${v}.inner";
outer = v: "${v}.outer";
any' = v: "${v}.*";
# 1 @assignment.inner
# 2 @assignment.lhs
# 3 @assignment.outer
# 4 @assignment.rhs
ass = "@assignment";
#-5 @attribute.inner
#-6 @attribute.outer
att = "@attribute";
# 7 @block.inner
# 8 @block.outer
blo = "@block";
# 9 @call.inner
# 10 @call.outer
cal = "@call";
# 11 @class.inner
# 12 @class.outer
cla = "@class";
#-13 @comment.inner
# 14 @comment.outer
com = "@comment";
# 15 @conditional.inner
# 16 @conditional.outer
con = "@conditional";
#-17 @frame.inner
#-18 @frame.outer
fra = "@frame";
# 19 @function.inner
# 20 @function.outer
fun = "@function";
# 21 @loop.inner
# 22 @loop.outer
loo = "@loop";
# 23 @number.inner
num = "@number";
# 24 @parameter.inner
# 25 @parameter.outer
par = "@parameter";
# 26 @regex.inner
# 27 @regex.outer
reg = "@regex";
# 28 @return.inner
# 29 @return.outer
ret = "@return";
#-30 @scopename.inner
# 31 @statement.outer
sta = "@statement";
in
{
select = {
enable = true;
lookahead = true;
selection_modes = {
"@parameter.outer" = "v"; # charwise
"@function.outer" = "V"; # linewise
"@class.outer" = ctrl "v"; # blockwise
};
};
swap = {
enable = true;
swap_next = {
"${localLeader "a"}" = {
query = [
(inner par)
(outer fun)
];
};
"${localLeader "f"}" = any' fun;
};
swap_previous = {
"${localLeader "A"}" = {
query = [
(inner par)
(outer fun)
];
};
"${localLeader "F"}" = any' fun;
};
};
move = {
enable = true;
set_jumps = true;
goto_next = {
"]q" = { query = map outer [ cla fun con loo ]; };
};
goto_previous = {
"[q" = { query = map outer [ cla fun con loo ]; };
};
};
};
};
2024-05-10 22:26:33 +03:00
};
plugins.style.neoformat.autoformat = {
2024-11-24 18:42:11 +03:00
enable = false;
pattern = [ "*.ts" "*.mts" "*.cts" "*.tsx" "*.rs" "flake.nix" ];
};
2024-05-10 02:39:22 +03:00
plugins.navigation = {
2024-11-25 23:29:07 +03:00
nvim-tree = {
enable = false;
settings = {
renderer = {
group_empty = true;
full_name = true;
};
tab.sync = {
open = true;
close = true;
};
2024-05-10 02:39:22 +03:00
};
};
telescope.extensions.telescope-live-grep-args-nvim.settings = {
auto_quoting = true;
mappings.i = {
"${ctrl "k"}" = pipe1
2024-05-10 02:39:22 +03:00
(require "telescope-live-grep-args.actions")
(call0 "quote_prompt")
;
};
};
};
2024-05-23 01:38:44 +03:00
plugins.snippet.luasnip.settings = {
ext_opts = [
(nf (var "luasnip_types.choiceNode") {
active.virt_text = [ [ "" "WarningMsg" ] ];
})
(nf (var "luasnip_types.insertNode") {
active.virt_text = [ [ "" "Title" ] ];
})
];
};
2024-05-10 02:39:22 +03:00
}