Add back null-ls

This commit is contained in:
Alexander Rosenberg 2023-08-18 10:44:33 -07:00
parent 7ae183d64b
commit a6a553c6b0
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
2 changed files with 78 additions and 33 deletions

View File

@ -191,42 +191,48 @@
:config
(module-call! :plugin.lsp :configure))
;; null-ls.nvim
(use! :jose-elias-alvarez/null-ls.nvim
:after :nvim-lspconfig
:config
(module-call! :plugin.lsp :setup-null-ls))
;; nvim-jdtls
(use! :mfussenegger/nvim-jdtls
:config
(module-call! :plugin.jdtls :configure))
;; formatter.nvim
(use! :mhartington/formatter.nvim
:cmd [ :Format :FormatWrite ]
:setup
(bind! :n :<leader>o "<cmd>Format<cr>")
(bind! :v :<leader>o ":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) ]
:tex [ (module-fn! :formatter.filetypes.latex :latexindent) ]
:python [ (module-fn! :formatter.filetypes.python :yapf) ]
:json [ (module-fn! :formatter.filetypes.json :prettier) ]
:html [ (module-fn! :formatter.filetypes.html :prettier) ]
:css [ (module-fn! :formatter.filetypes.css :prettier) ]
:javascript [ (module-fn! :formatter.filetypes.javascript :prettier) ]
:markdown [
(module-fn! :formatter.filetypes.markdown :prettier ) ]
:fennel [ (fn [] {:exe :fnlfmt
:stdin true
:args [ "-" ]})]}))
;(use! :mhartington/formatter.nvim
; :cmd [ :Format :FormatWrite ]
; :setup
; (bind! :n :<leader>o "<cmd>Format<cr>")
; (bind! :v :<leader>o ":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) ]
; :tex [ (module-fn! :formatter.filetypes.latex :latexindent) ]
; :python [ (module-fn! :formatter.filetypes.python :yapf) ]
; :json [ (module-fn! :formatter.filetypes.json :prettier) ]
; :html [ (module-fn! :formatter.filetypes.html :prettier) ]
; :css [ (module-fn! :formatter.filetypes.css :prettier) ]
; :javascript [ (module-fn! :formatter.filetypes.javascript :prettier) ]
; :markdown [
; (module-fn! :formatter.filetypes.markdown :prettier ) ]
; :fennel [ (fn [] {:exe :fnlfmt
; :stdin true
; :args [ "-" ]})]}))
;; Sync all packages on first launch
(if _G.first_launch

View File

@ -21,8 +21,13 @@
(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)
(when (= client.name :rust_analyzer)
(bind! [ :n :v ] :<leader>o #(vim.lsp.buf.format {:async true})))
(bind! [ :n :v ] :<leader>o
#(vim.lsp.buf.format { :filter
;; use null-ls for formatting
(fn [client] (or
(= client.name :null-ls)
(= client.name :rust_analyzer)))
:async true }) buf)
;; Use builtin formatexpr
(vim.api.nvim_buf_set_option buf :formatexpr "")
@ -106,4 +111,38 @@
:diagnostics {
:globals [ "vim" ] }}})))
{: configure : on-attach : get-data-dir }
(fn setup-null-ls []
(let [builtins (. (require :null-ls) :builtins)]
(setup! :null-ls
:on_attach (fn [client buf]
(bind! [ :n :v ]
:<leader>o
#(vim.lsp.buf.format
{ :filter
;; use null-ls for formatting
(fn [client]
(or
(= client.name :null-ls)
(= client.name :rust_analyzer)))
:async true }) buf)
(vim.api.nvim_buf_set_option buf :formatexpr ""))
:sources [
builtins.formatting.astyle
builtins.formatting.prettier
builtins.formatting.yapf
builtins.formatting.fnlfmt
builtins.formatting.shfmt
builtins.formatting.cmake_format
builtins.formatting.latexindent
builtins.formatting.stylua
builtins.code_actions.shellcheck
(builtins.completion.spell.with { :filetypes [ :text
:markdown
:tex ]})
builtins.diagnostics.cmake_lint
;;builtins.diagnostics.codespell
;;builtins.diagnostics.shellcheck
(builtins.diagnostics.glslc.with
{ :extra_args [ "--target-env=opengl" ]})])))
{: configure : on-attach : get-data-dir : setup-null-ls }