Added formatter
This commit is contained in:
parent
0386262448
commit
d6d1936973
@ -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 :<leader>fp "<cmd>FzfLua spell_suggest<cr>")
|
||||
(bind! :n :<leader>i "<cmd>FzfLua files<cr>")
|
||||
(bind! :n :z= "<cmd>FzfLua spell_suggest<cr>")
|
||||
(bind! :n :<leader>ff (fn []
|
||||
(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")))))
|
||||
(vim.cmd "FzfLua files"))))
|
||||
(bind! :n :<leader>ff list-git-or-default)
|
||||
(bind! :n :<leader>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 :<leader>o "<cmd>Format<cr>")
|
||||
: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
|
||||
|
@ -21,7 +21,7 @@
|
||||
(bind! :n :<leader>rn vim.lsp.buf.rename buf)
|
||||
; (bind! :n :<leader>cn vim.lsp.buf.code_action buf)
|
||||
; (bind! :n :gr vim.lsp.buf.references buf)
|
||||
(bind! :n :<leader>o #(vim.lsp.buf.format { :async true }) buf)
|
||||
; (bind! :n :<leader>o #(vim.lsp.buf.format { :async true }) buf)
|
||||
|
||||
;; Some fzf commands
|
||||
(bind! :n :gr "<cmd>FzfLua lsp_references<cr>" buf)
|
||||
|
Reference in New Issue
Block a user