From cad385b8a76172859fbed2ca3131f93a7b53a854 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 17 May 2024 22:26:17 +0300 Subject: [PATCH] neovim: update configs --- flake.lock | 8 ++--- neovim/dev.nix | 83 +++++++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/flake.lock b/flake.lock index fbda986..57bb2d9 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ ] }, "locked": { - "lastModified": 1715948824, - "narHash": "sha256-oaskTqPfJ5J0xXHW6wA7DpUZRMagKJSlQ6RdkETlx4s=", + "lastModified": 1715970214, + "narHash": "sha256-x9bHVtPmk5BfGmVLfUhFcpVJdQZ5SstBRFy19WBp/W0=", "ref": "refs/heads/main", - "rev": "37156d182b912a8ecb575157f6ac002d68c4483b", - "revCount": 70, + "rev": "51fcb9d9e41d9ac540a9840081fdce328e2117e0", + "revCount": 73, "type": "git", "url": "https://git.pleshevski.ru/pleshevskiy/nixeovim" }, diff --git a/neovim/dev.nix b/neovim/dev.nix index 1a6470d..a2e104b 100644 --- a/neovim/dev.nix +++ b/neovim/dev.nix @@ -2,60 +2,67 @@ let inherit (lib.mod) ctrl; - inherit (lib.nix2lua) lambda0 set pipe1 require call call0; + inherit (lib.nix2lua) pipe1 require call call0; - mkLineLimiterGroup = { limit, pattern }: { - "line-limiter-${toString limit}" = { - event = [ "BufNewFile" "BufRead" ]; - inherit pattern; - callback = lambda0 (set "vim.wo.colorcolumn" (toString limit)); - }; - }; + mkLineLimiterGroup = { limit, filetypes }: + lib.nameValuePair + "line-limiter-${toString limit}" + { + inherit filetypes; + opt = { + colorcolumn = toString limit; + textwidth = limit; + }; + }; in { imports = [ "${modulesPath}/profiles/recommended.nix" ]; + vim.opt = { + list = true; + formatexpr = "neoformat#Neoformat(0, '', v:lnum, v:lnum + v:count)"; + }; + + buffer = { + nix.opt.formatexpr = "neoformat#Neoformat(0, '', 0, 99999)"; + } // lib.listToAttrs [ + (mkLineLimiterGroup { + limit = 101; + filetypes = [ + "nix" + "javascript,javascriptreact" + "typescript,typescriptreact" + "rust" + "haskell" + ]; + }) + (mkLineLimiterGroup { + limit = 81; + filetypes = [ + "json" + "yaml" + "markdown" + "html" + "css" + "scss" + "less" + "sql" + "psql" + ]; + }) + ]; + filetype.detect = { d2 = "*.d2"; nickel = "*.ncl"; psql = "*.psql"; }; - vim.opt.list = true; - # Enable fast navigation between windows vim.keymap.set = map (k: { mode = "n"; lhs = ctrl k; rhs = "${ctrl "w"}${k}"; }) [ "h" "l" "j" "k" ]; - vim.augroup = lib.mkMerge [ - (mkLineLimiterGroup { - limit = 101; - pattern = [ - "*.nix" - "*.ts" - "*.tsx" - "*.js" - "*.jsx" - "*.rs" - "*.hs" - ]; - }) - (mkLineLimiterGroup { - limit = 81; - pattern = [ - "*.json" - "*.yml" - "*.yaml" - "*.md" - "*.html" - "*.css" - "*.scss" - "*.less" - ]; - }) - ]; - plugins.style.nvim-treesitter.extraGrammars = { tree-sitter-d2 = rec { language = "d2";