diff options
Diffstat (limited to 'fnl')
-rw-r--r-- | fnl/nvrc/keymaps.fnl | 2 | ||||
-rw-r--r-- | fnl/nvrc/pack.fnl | 1 | ||||
-rw-r--r-- | fnl/nvrc/packs/conform.fnl | 25 |
3 files changed, 27 insertions, 1 deletions
diff --git a/fnl/nvrc/keymaps.fnl b/fnl/nvrc/keymaps.fnl index c98a78a..fd74449 100644 --- a/fnl/nvrc/keymaps.fnl +++ b/fnl/nvrc/keymaps.fnl @@ -80,7 +80,7 @@ ; LSP (map! [n] :fl (vim.lsp.buf.declaration)) (map! [n] :fd (vim.lsp.buf.definition)) -(map! [n] :fs (vim.lsp.buf.format)) +(map! [nv :silent] :fs ":ConformFormat<cr>") (map! [n] :fa (vim.lsp.buf.code_action)) (map! [n] :fu (vim.lsp.buf.implementation)) (map! [n] :fi (vim.lsp.buf.incoming_calls)) diff --git a/fnl/nvrc/pack.fnl b/fnl/nvrc/pack.fnl index 207d3f6..e041211 100644 --- a/fnl/nvrc/pack.fnl +++ b/fnl/nvrc/pack.fnl @@ -44,6 +44,7 @@ :dependencies [(pack :lukas-reineke/cmp-under-comparator) (pack :hrsh7th/cmp-nvim-lsp {:after :nvim-cmp}) (pack :hrsh7th/cmp-nvim-lsp-signature-help)]}) +(pack! :stevearc/conform.nvim {:req :conform :cmd [:ConformInfo :ConformFormat] :keys ["gq"]}) (pack! :numToStr/Comment.nvim {:init :Comment :lazy true}) (pack! :ibhagwan/fzf-lua {:req :fzf :lazy true}) (pack! :ggandor/leap.nvim {:req :leap :keys [:s :S]}) diff --git a/fnl/nvrc/packs/conform.fnl b/fnl/nvrc/packs/conform.fnl new file mode 100644 index 0000000..b9e3737 --- /dev/null +++ b/fnl/nvrc/packs/conform.fnl @@ -0,0 +1,25 @@ +(import-macros {: set!} :nvrc.macro.set) +(local {: setup :conform-formatexpr formatexpr} (require :conform)) + +(setup {:formatters_by_ft {:nix [:nixpkgs_fmt]}}) + +(set! formatexpr "v:lua.require'conform'.formatexpr({ lsp_fallback = 'always' })") + +(vim.api.nvim_create_user_command :ConformFormat +(fn [args] + (var range nil) + (when (not= args.count (- 1)) + (local end-line + (. (vim.api.nvim_buf_get_lines 0 + (- args.line2 + 1) + args.line2 + true) + 1)) + (set range + {:end [args.line2 (end-line:len)] + :start [args.line1 0]})) + ((. (require :conform) :format) {:async true + :lsp_fallback :always + : range})) +{:range true}) |