diff --git a/fnl/plugin.fnl b/fnl/plugin.fnl index 8e5c3f0..ba9f165 100644 --- a/fnl/plugin.fnl +++ b/fnl/plugin.fnl @@ -2,7 +2,8 @@ (import-macros {: bind! : hook! : use! : setup! - : module-call! } :macros) + : module-call! + : module-fn! } :macros) (fn [use] ;; Packer @@ -80,11 +81,13 @@ (bind! :n :fp "FzfLua spell_suggest") (bind! :n :i "FzfLua files") (bind! :n :z= "FzfLua spell_suggest") - (bind! :n :ff (fn [] - (let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")] - (if (= code 0) - (vim.cmd "FzfLua git_files") - (vim.cmd "FzfLua files"))))) + (fn list-git-or-default [] + (let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")] + (if (= code 0) + (vim.cmd "FzfLua git_files") + (vim.cmd "FzfLua files")))) + (bind! :n :ff list-git-or-default) + (bind! :n :u list-git-or-default) (fn jump-or-open-terminal [] "If no terminal buffer exists, create one. Otherwise, open new one." (var term_count 0) @@ -223,6 +226,33 @@ :config (setup! :guess-indent :auto_cmd true)) + ;; formatter + (use! :mhartington/formatter.nvim + :cmd [ :Format :FormatWrite ] + :setup + (bind! :n :o "Format") + :config + (setup! :formatter + :logging true + :log_level _G.vim.log.levels.WARN + :filetype { + :c [ (module-fn! :formatter.filetypes.c :astyle) ] + :cpp [ (module-fn! :formatter.filetypes.cpp :astyle) ] + :cmake [ + (module-fn! :formatter.filetypes.cmake :cmakeformat) ] + :java [ + (fn [] {:exe :astyle + :stdin true + :args [ :--mode=java ]}) ] + :sh [ + (module-fn! :formatter.filetypes.sh :shfmt) ] + :rust [ + (module-fn! :formatter.filetypes.rust :rustfmt) ] + :fennel [ + (fn [] {:exe :fnlfmt + :stdin true + :args [ "-" ]}) ]})) + ;; lspconfig (use! :neovim/nvim-lspconfig :after :cmp-nvim-lsp diff --git a/fnl/plugin/lsp.fnl b/fnl/plugin/lsp.fnl index 45a0450..fdb2641 100644 --- a/fnl/plugin/lsp.fnl +++ b/fnl/plugin/lsp.fnl @@ -21,7 +21,7 @@ (bind! :n :rn vim.lsp.buf.rename buf) ; (bind! :n :cn vim.lsp.buf.code_action buf) ; (bind! :n :gr vim.lsp.buf.references buf) - (bind! :n :o #(vim.lsp.buf.format { :async true }) buf) + ; (bind! :n :o #(vim.lsp.buf.format { :async true }) buf) ;; Some fzf commands (bind! :n :gr "FzfLua lsp_references" buf) diff --git a/init.fnl b/init.fnl index 9c8c48f..2822a54 100644 --- a/init.fnl +++ b/init.fnl @@ -99,8 +99,4 @@ "h" :c "ui" :xml }}) -;; Better fennel formatting -(hook! :FileType [ :fennel ] - #(set vim.opt_local.formatprg "fnlfmt -")) - (module-call! :packer :startup (require :plugin))