1
0
Fork 0

Compare commits

...

4 commits

Author SHA1 Message Date
eceae40d63
Update deps
All checks were successful
Build / build-arm64-linux (push) Successful in 9m33s
Build / build-amd64-linux (push) Successful in 44m54s
2023-10-09 18:30:27 +02:00
1c8c36f0b4
nvim: More plugin cleanup 2023-10-09 18:07:32 +02:00
95703b4c6f
Update deps 2023-10-09 15:08:07 +02:00
f497dba501
nvim: Use conform for formatting 2023-10-09 15:05:57 +02:00
9 changed files with 104 additions and 163 deletions

View file

@ -109,11 +109,11 @@
]
},
"locked": {
"lastModified": 1696468923,
"narHash": "sha256-qSM7NKgf8LcZ5hjKHZ8ANFI8+LQivvAypbhJHBJmYFM=",
"lastModified": 1696814493,
"narHash": "sha256-1qArVsJGG2RHbV2iKFpAmM5os3myvwpXMOdFy5nh54M=",
"owner": "nix-community",
"repo": "disko",
"rev": "cde886a1c97ef2399b4f91409db045785020291f",
"rev": "32ce057c183506cecb0b84950e4eaf39f37e8c75",
"type": "github"
},
"original": {
@ -325,11 +325,11 @@
},
"locked": {
"dir": "contrib",
"lastModified": 1696761399,
"narHash": "sha256-9nR5ydhnN3IvRx/UfZZ09QV7SL4uNfhBRx4UGuNKCDw=",
"lastModified": 1696856736,
"narHash": "sha256-ynnnyO04fGaySr1F08P6J/wH7wY6+YDjsVNcGqqCzlc=",
"owner": "neovim",
"repo": "neovim",
"rev": "30d311ebcf9433f84bd4d98f9e049b36c9d352ac",
"rev": "55be4a4e26eafd06704a465ce85cf9526115e0f1",
"type": "github"
},
"original": {
@ -350,11 +350,11 @@
]
},
"locked": {
"lastModified": 1696761760,
"narHash": "sha256-OdF9XVxnJU9NwaBHQ0NOIR07koAWQKpBDTyL58c3fNA=",
"lastModified": 1696856794,
"narHash": "sha256-5/SMa9LWm/0PYFQWRAQcH23PYF2z+v99iYlYrLD6gYQ=",
"ref": "refs/heads/master",
"rev": "92f1abecccbfa249258ee8b5ce8f632c28f967ee",
"revCount": 520,
"rev": "ec2ddd34272a42f16f963c59ce494712b2fe6b9e",
"revCount": 521,
"type": "git",
"url": "https://git.kempkens.io/daniel/nix-overlay"
},
@ -401,11 +401,11 @@
},
"nixos-unstable": {
"locked": {
"lastModified": 1696729975,
"narHash": "sha256-Bgm3GFrNftDwDbnNYvKzeX1jW5euOLif5ZsvYsYYq30=",
"lastModified": 1696826630,
"narHash": "sha256-oGU94vo6pkzGbaSsPHjpHtOUg6b7nL8v3xATnrcw3cQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0cbdedb436366db9863df099a934306028ed21ca",
"rev": "5a9c737c587d2c34d63c5b3cb53c6ab0705bdf4f",
"type": "github"
},
"original": {
@ -417,11 +417,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1696725822,
"narHash": "sha256-B7uAOS7TkLlOg1aX01rQlYbydcyB6ZnLJSfaYbKVww8=",
"lastModified": 1696757521,
"narHash": "sha256-cfgtLNCBLFx2qOzRLI6DHfqTdfWI+UbvsKYa3b3fvaA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5aabb5780a11c500981993d49ee93cfa6df9307b",
"rev": "2646b294a146df2781b1ca49092450e8a32814e1",
"type": "github"
},
"original": {
@ -492,11 +492,11 @@
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1696773021,
"narHash": "sha256-JzjKl1h96cM5iSrkNvZX7Fgo+e3lisv2tn+uIMnXmD4=",
"lastModified": 1696846637,
"narHash": "sha256-0hv4kbXxci2+pxhuXlVgftj/Jq79VSmtAyvfabCCtYk=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "8edf336c5ca85efe20004d076747f91b85a6d087",
"rev": "42e1b6095ef80a51f79595d9951eb38e91c4e6ca",
"type": "github"
},
"original": {

View file

@ -2,24 +2,22 @@
b vim.b
api vim.api
set-bufvar vim.api.nvim_buf_set_var
format (require :format)]
conform (require :conform)]
(fn mod.setup []
(let [usercmd vim.api.nvim_create_user_command
augroup (vim.api.nvim_create_augroup :NifocFormatting {:clear true})
aucmd vim.api.nvim_create_autocmd]
(let [usercmd api.nvim_create_user_command
augroup (api.nvim_create_augroup :NifocFormatting {:clear true})
aucmd api.nvim_create_autocmd]
(usercmd :FormatDisableBuffer mod.disable-for-buffer
{:desc "Disable Formatting for the current buffer"})
(usercmd :FormatEnableBuffer mod.enable-for-buffer
{:desc "Enable Formatting for the current buffer"})
;; (aucmd :BufWritePre
;; {:callback mod.maybe-format-buffer
;; :group augroup
;; :desc "Run Formatter before saving"})
))
(aucmd :BufWritePre
{:callback mod.maybe-format-buffer
:group augroup
:desc "Run Formatter before saving"})))
(fn has-formatter-config? [ft]
(let [cfg (. (require :format.static) :config)
fts (. cfg :filetypes)]
(let [fts conform.formatters_by_ft]
(not= (. fts ft) nil)))
(fn format-with-lsp? [ft]
@ -35,17 +33,11 @@
(fn mod.active? []
(let [ft vim.bo.filetype]
(if (= b.nifoc_formatter_disabled 1) false
(has-formatter-config? ft))))
(fn mod.maybe-enable-lsp [client bufnr]
(when (client.supports_method :textDocument/rangeFormatting)
(api.nvim_buf_set_option bufnr :formatexpr "v:lua.vim.lsp.formatexpr()")))
(or (has-formatter-config? ft) (format-with-lsp? ft)))))
(fn mod.maybe-format-buffer []
(let [ft vim.bo.filetype]
(if (= b.nifoc_formatter_disabled 1) nil
(format-with-lsp? ft) (vim.lsp.buf.format)
(has-formatter-config? ft) (format.format)
nil)))
(conform.format {:lsp_fallback (format-with-lsp? ft)}))))
mod)

View file

@ -52,10 +52,7 @@
{:desc "Show Diagnostics"})
(keymap.set :n :<leader>dtp :<cmd>TSPlaygroundToggle<CR>
{:desc "Toggle Treetsitter Playground"})
; (keymap.set :n :<leader>dn #(noice.cmd :telescope)
; {:desc "Display Notifications"})
;; Other Mappings
; (keymap.set :n :<CR> ":nohlsearch<CR><CR>" {:silent true})
(keymap.set :n :F formatting.maybe-format-buffer {:desc "Format Buffer"})
(keymap.set :n :<A-Left> :b)
(keymap.set :n :<A-Right> :w)
@ -109,4 +106,3 @@
(keymap.set :t :<C-l> "<C-\\><C-n><C-W>l" map-opts)))
mod)

View file

@ -1,15 +1,9 @@
(let [M {}
format (require :format)
format-core (require :core)
(let [conform (require :conform)
conform-util (require :conform.util)
toml (require :toml)
treefmt-config-file vim.env.TREEFMT_CONFIG_FILE
treefmt-exts []
level vim.log.levels]
(var latest-used-formatter :unknown)
(fn notify [msg lvl]
(vim.notify (.. msg " [" latest-used-formatter "]") lvl {:title :Format}))
tmp-filename "\$FILENAME"]
(fn read-file [file]
(with-open [f (io.open file :rb)]
(f:read :*all)))
@ -19,57 +13,44 @@
(each [_ opts (pairs cfg.formatter)]
(vim.list_extend treefmt-exts opts.includes))))
(fn treefmt-or-fallback [file-path fallback]
(let [ext (format-core.file.extension file-path)
(fn treefmt-or-fallback [fallback]
(let [ext (vim.fn.expand "%:e")
ext-glob (.. "*." ext)]
(if (vim.list_contains treefmt-exts ext-glob)
(do
(set latest-used-formatter :treefmt)
[{:cmd :treefmt
:args [file-path]
:ignore_err (fn [err data]
(and (= err nil) (not (string.find data :Error))))}])
(= (vim.fn.executable fallback.cmd) 1)
(do
(set latest-used-formatter fallback.cmd)
[fallback])
{:command :treefmt
:args [tmp-filename]
:stdin false
:cwd (conform-util.root_file [:flake.nix :flake.lock])
:require_cwd true}
(= (vim.fn.executable fallback.command) 1)
fallback
[])))
(fn formatter-prettier [file-path]
(treefmt-or-fallback file-path {:cmd :prettier :args [:--write file-path]}))
(fn M.treefmt-extensions [] treefmt-exts)
(format.setup {:filetypes {:css formatter-prettier
:fennel (fn [file-path]
(treefmt-or-fallback file-path
{:cmd :fnlfmt
:args [:--fix
file-path]}))
:fish (fn [file-path]
{:cmd :fish_indent
:args [:--write file-path]})
:html formatter-prettier
:javascript formatter-prettier
:json formatter-prettier
:nix (fn [file-path]
(treefmt-or-fallback file-path
{:cmd :nixpkgs-fmt
:args [file-path]}))
:sh (fn [file-path]
(treefmt-or-fallback file-path
{:cmd :shfmt
:args [:-i
(conform.setup {:formatters_by_ft {:css [:treefmt_or_prettier]
:elixir [:mix]
:fennel [:treefmt_or_fnlfmt]
:fish [:fish_indent]
:html [:treefmt_or_prettier]
:javascript [:treefmt_or_prettier]
:json [:treefmt_or_prettier]
:nix [:treefmt_or_nixpkgs_fmt]
:sh [:treefmt_or_shfmt]
:typescript [:treefmt_or_prettier]
:yaml [:treefmt_or_yamlfmt]}
:notify_on_error true
:formatters {:treefmt_or_fnlfmt #(treefmt-or-fallback {:command :fnlfmt
:args ["-"]})
:treefmt_or_nixpkgs_fmt #(treefmt-or-fallback {:command :nixpkgs-fmt})
:treefmt_or_prettier #(treefmt-or-fallback {:command :prettier
:args [:--stdin-filepath
tmp-filename]
:cwd (conform-util.root_file [:.prettierrc
:package.json])})
:treefmt_or_shfmt #(treefmt-or-fallback {:command :shfmt
:args [:-filename
tmp-filename
:-i
:2
:-s
:-w
file-path]}))
:typescript formatter-prettier
:yaml (fn [file-path]
(treefmt-or-fallback file-path
{:cmd :yamlfmt
:args [file-path]}))}
:hooks {:on_success #(notify "Formatting Succeed" level.INFO)
:on_err #(notify "Formatting Failed" level.ERROR)
:on_timeout #(notify "Formatting Timeout" level.ERROR)}})
M)
:-s]})
:treefmt_or_yamlfmt #(treefmt-or-fallback {:command :yamlfmt
:args ["-"]})}}))

View file

@ -3,7 +3,6 @@
coq (require :coq)
navic (require :nvim-navic)
diagnostic (require :nifoc.diagnostic)
formatting (require :nifoc.formatting)
augroup (vim.api.nvim_create_augroup :NifocLsp {:clear true})
aucmd vim.api.nvim_create_autocmd]
(fn setup-inlay-hint-toggle [bufnr]
@ -24,7 +23,6 @@
(vim.lsp.inlay_hint bufnr true)
(setup-inlay-hint-toggle bufnr))
(diagnostic.maybe-enable-lsp client bufnr)
(formatting.maybe-enable-lsp client bufnr)
((. (require :lsp-notify) :setup) {})))
:group augroup
:desc "Automatic LSP setup"})

View file

@ -1,5 +1,7 @@
(let [miniclue (require :mini.clue)
hipatterns (require :mini.hipatterns)]
;; https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-ai.md
((. (require :mini.ai) :setup) {})
;; https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-clue.md
(miniclue.setup {:triggers [; Leader
{:mode :n :keys :<leader>}

View file

@ -224,10 +224,8 @@ in
# Formatting
core-nvim
{
plugin = format-nvim;
plugin = conform-nvim;
config = builtins.readFile ../../config/nvim/plugins/formatter.fnl;
type = "fennel";
}
@ -239,9 +237,6 @@ in
type = "fennel";
}
# Textobjects
nvim-treesitter-textobjects
# UI
{
plugin = heirline-nvim;
@ -321,7 +316,7 @@ in
for fnlfile in $nifoc_store_fnl; do
file_out_path="$(echo "$fnlfile" | sed "s|$nifoc_store_path/||" | sed "s/.fnl$/.lua/")"
echo "Compiling $fnlfile ..."
echo "Compiling $fnlfile -> $out/lua/nifoc/$file_out_path"
$fennel "$fnlfile" > "$out/lua/nifoc/$file_out_path"
done
@ -332,7 +327,7 @@ in
for fnlfile in $ftplugin_store_fnl; do
file_out_path="$(echo "$fnlfile" | sed "s|$ftplugin_store_path/||" | sed "s/.fnl$/.lua/")"
echo "Compiling $fnlfile ..."
echo "Compiling $fnlfile -> $out/ftplugin/$file_out_path"
$fennel "$fnlfile" > "$out/ftplugin/$file_out_path"
done
@ -343,7 +338,7 @@ in
for fnlfile in $after_store_fnl; do
file_out_path="$(echo "$fnlfile" | sed "s|$after_store_path/||" | sed "s/.fnl$/.lua/")"
echo "Compiling $fnlfile ..."
echo "Compiling $fnlfile -> $out/after/$file_out_path"
$fennel "$fnlfile" > "$out/after/$file_out_path"
done
@ -354,7 +349,9 @@ in
${config.programs.neovim.generatedConfigs.fennel}
nil
EOF
} | $fennel - > "$out/lua/configuration/plugins.lua"
} > "$out/lua/configuration/plugins.fnl"
$fennel "$out/lua/configuration/plugins.fnl" > "$out/lua/configuration/plugins.lua"
rm -f "$out/lua/configuration/plugins.fnl"
# Other
echo "Copying tree-sitter queries ..."

View file

@ -30,23 +30,23 @@ in
};
mini-nvim = buildVimPlugin {
pname = "mini.nvim";
version = "2023-10-03";
version = "2023-10-09";
src = fetchFromGitHub {
owner = "echasnovski";
repo = "mini.nvim";
rev = "25c4bf4efac51aad5393e37949e68ac3e672a73c";
sha256 = "115s6wjd7c0y2fcc0wnzdp2gp1qmwzy417jqzjmlb1rphj7kn2hz";
rev = "0c50ef9d0b7cae1145f3365e7bcf9ed01bc00005";
sha256 = "1il169wvz995k42is9b6baz5ii0fh6513q42qmv927s04k6vja0w";
fetchSubmodules = false;
};
};
nvim-web-devicons = buildVimPlugin {
pname = "nvim-web-devicons";
version = "2023-10-08";
version = "2023-10-09";
src = fetchFromGitHub {
owner = "kyazdani42";
repo = "nvim-web-devicons";
rev = "56b3a6ce6d69329cbf603dd38ac59fb4d7774b01";
sha256 = "1gqfzbdkiv91wvb14ydspjh1z4w59lp8rdsyw3w1gskfjalwz6cq";
rev = "a1e6268779411048a87f767a27380089362a0ce2";
sha256 = "019i9iy9zri12whq5kdpfia8zbpp7x5p5snk4j6bb0p7hb7caljp";
fetchSubmodules = false;
};
};
@ -96,12 +96,12 @@ in
};
substitute-nvim = buildVimPlugin {
pname = "substitute.nvim";
version = "2023-10-05";
version = "2023-10-09";
src = fetchFromGitHub {
owner = "gbprod";
repo = "substitute.nvim";
rev = "49f6f4992f244242cd522572631c34b0a89c54cb";
sha256 = "0wmbx66d47dajc822g31xrqdymma9jky14s3dfxvbdwzzxab9ipp";
rev = "523047fac696ab2acdbfd6fec707587c64d6f9d7";
sha256 = "02c1w2yqi1dir59rvxyiyp9vk4r9n0vffvk3gm0lh31b9nf2lfhc";
fetchSubmodules = false;
};
};
@ -118,12 +118,12 @@ in
};
nvim-treesitter = buildVimPlugin {
pname = "nvim-treesitter";
version = "2023-10-08";
version = "2023-10-09";
src = fetchFromGitHub {
owner = "nvim-treesitter";
repo = "nvim-treesitter";
rev = "a102053352bd958d84a3e1be3de0203d2af92984";
sha256 = "176k4hahgcjly971abrpf4q0279ll6my7qlxs0bdjf2g9095aijj";
rev = "1d1c32b64b17b866152f29a3676a719cb6078028";
sha256 = "1m1lmkxsrag3zdqd2f7ghk7wsjjrrx9fmsffjkphsdwdfq7q3vy0";
fetchSubmodules = false;
};
};
@ -133,8 +133,8 @@ in
src = fetchFromGitHub {
owner = "NoahTheDuke";
repo = "vim-just";
rev = "fbcfcf96cf7c67cf0d4ad15b7af5069f65440c4f";
sha256 = "1awabcqs6rci0xn7nhzy5ra69ppq8lql0k5ky7vxwv0jjwnn6ac0";
rev = "b2113d846c1f5a400ac9c2f5ef762de8f99dc745";
sha256 = "14nqxx0lmqbydcxxjxy2jw0nkgawlkcl4bjnm38wvyj5vibhmy8v";
fetchSubmodules = false;
};
};
@ -275,34 +275,23 @@ in
};
nvim-lint = buildVimPlugin {
pname = "nvim-lint";
version = "2023-10-06";
version = "2023-10-09";
src = fetchFromGitHub {
owner = "mfussenegger";
repo = "nvim-lint";
rev = "edb0a845bcc04e4f0c99950a360314df9111822d";
sha256 = "1sg52x48qlk5i3s3agsvkm7dabbay1d8ff3xnima57i393llksmb";
rev = "79ffe0f63d1e7545157f246e7eaa74e07fea1612";
sha256 = "0di2izyk8vic11yfxdcasfmajyzlmsbdp1jz25bygzw078zd2spl";
fetchSubmodules = false;
};
};
core-nvim = buildVimPlugin {
pname = "core.nvim";
version = "2023-09-09";
conform-nvim = buildVimPlugin {
pname = "conform.nvim";
version = "2023-10-09";
src = fetchFromGitHub {
owner = "niuiic";
repo = "core.nvim";
rev = "dc1046613c7a0ce664b6ec3d5c8c94d6b6d2618d";
sha256 = "0lgg800rcrkg99wg7spj1r9ykyx31zr07f57ybyqaxwd7z0sx260";
fetchSubmodules = false;
};
};
format-nvim = buildVimPlugin {
pname = "format.nvim";
version = "2023-09-17";
src = fetchFromGitHub {
owner = "niuiic";
repo = "format.nvim";
rev = "5bc6846406dcb791edbf02f847fc687b74c45ec7";
sha256 = "0jizp5hb0clcdbl965b4pbci1cch00mj07w1cbg3j3yaz7d9lwf6";
owner = "stevearc";
repo = "conform.nvim";
rev = "9bd169029ac7fac5d0b3899a47556549d113a4c2";
sha256 = "1jp0pdg1hbm1pms7cxiy6mpi2kdk23m4g0fpbfr1v2n8ql19196s";
fetchSubmodules = false;
};
};
@ -317,17 +306,6 @@ in
fetchSubmodules = false;
};
};
nvim-treesitter-textobjects = buildVimPlugin {
pname = "nvim-treesitter-textobjects";
version = "2023-10-07";
src = fetchFromGitHub {
owner = "nvim-treesitter";
repo = "nvim-treesitter-textobjects";
rev = "76c7a89b41de77a4f83fb77fa072c5ad7605fe3b";
sha256 = "0438xz3k77xfmnvi210sxn4wda89nnw63a45ab2c5hvnhny9m0vm";
fetchSubmodules = false;
};
};
heirline-nvim = buildVimPlugin {
pname = "heirline.nvim";
version = "2023-09-03";

View file

@ -33,12 +33,9 @@
# Linter
- src: mfussenegger/nvim-lint
# Formatting
- src: niuiic/core.nvim
- src: niuiic/format.nvim
- src: stevearc/conform.nvim
# Pairs
- src: andymass/vim-matchup
# Textobjects
- src: nvim-treesitter/nvim-treesitter-textobjects
# UI
- src: rebelot/heirline.nvim
- src: lukas-reineke/indent-blankline.nvim