Added null-fs
This commit is contained in:
parent
d37c20404d
commit
198ad1377f
@ -1,7 +1,7 @@
|
||||
;;; macros.fnl - useful macros
|
||||
|
||||
;; Helpful keymaping functions
|
||||
(lambda bind! [mode key cmd ?a1 ?a2]
|
||||
(lambda bind! [modes key cmd ?a1 ?a2]
|
||||
(let [desc (or ?a2 ?a1)
|
||||
buf (if (and ?a1 ?a2) ?a1 ?a2)
|
||||
opts { :noremap true
|
||||
@ -9,7 +9,12 @@
|
||||
:buffer buf }]
|
||||
(when desc
|
||||
(tset opts :desc desc))
|
||||
`(vim.keymap.set ,mode ,key ,cmd ,opts)))
|
||||
(if (table? modes)
|
||||
(let [output {}]
|
||||
(each [_ mode (ipairs modes)]
|
||||
(table.insert output `(vim.keymap.set ,mode ,key ,cmd ,opts)))
|
||||
output)
|
||||
`(vim.keymap.set ,modes ,key ,cmd ,opts))))
|
||||
|
||||
;; Better autocommands
|
||||
(lambda hook! [hooks ?patterns callback]
|
||||
@ -21,7 +26,7 @@
|
||||
(= (type ?patterns) :table)
|
||||
?patterns
|
||||
[ ?patterns ])]
|
||||
(var group "config-hook")
|
||||
(var group (.. (tostring (math.random 0 1000000000) "-config-hook")))
|
||||
(each [_ hook (ipairs hook_table)]
|
||||
(set group (.. group "-" hook)))
|
||||
(each [_ pattern (ipairs pattern_table)]
|
||||
|
@ -62,13 +62,15 @@
|
||||
:show_buffer_close_icons false
|
||||
:show_close_icon false }))
|
||||
|
||||
(use! :nvim-lua/plenary.nvim
|
||||
:opt true
|
||||
:module :plenary)
|
||||
|
||||
;; telescope (a fuzzy finder)
|
||||
(use! :nvim-telescope/telescope.nvim
|
||||
:cmd :Telescope
|
||||
:module :telescope
|
||||
:requires [ { 1 :nvim-lua/plenary.nvim
|
||||
:opt true }
|
||||
{ 1 :nvim-telescope/telescope-ui-select.nvim
|
||||
:requires [ { 1 :nvim-telescope/telescope-ui-select.nvim
|
||||
:opt true }
|
||||
{ 1 :nvim-telescope/telescope-fzf-native.nvim
|
||||
:opt true
|
||||
@ -119,22 +121,6 @@
|
||||
:config
|
||||
(setup! :Comment))
|
||||
|
||||
;; nvim-find-other
|
||||
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
|
||||
:config
|
||||
(setup! :nvim-find-other
|
||||
:c [ "h" "H" ]
|
||||
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
|
||||
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
||||
:tpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
||||
:hpp [ "cpp" "tpp" "cxx" "c++" "cc" ])
|
||||
(let [find-other (require :nvim-find-other)]
|
||||
(vim.api.nvim_create_user_command
|
||||
"FindOtherFile"
|
||||
find-other.find_other_current_buffer
|
||||
{})
|
||||
(bind! :n :go find-other.find_other_current_buffer)))
|
||||
|
||||
;; illuminate (same symbol highlight)
|
||||
(use! :RRethy/vim-illuminate
|
||||
:config
|
||||
@ -154,18 +140,6 @@
|
||||
:IlluminatedWordText
|
||||
{})))
|
||||
|
||||
;; vlime (lisp environment)
|
||||
(use! :vlime/vlime
|
||||
:ft :lisp
|
||||
:config
|
||||
(set vim.g.vlime_cl_impl :my_sbcl)
|
||||
(set vim.g.vlime_address [ "127.0.0.1" 52842 ])
|
||||
(vim.cmd "function! VlimeBuildServerCommandFor_my_sbcl(vlime_loader, vlime_eval)
|
||||
return [ \"/usr/bin/sbcl\",
|
||||
\\ \"--load\", a:vlime_loader,
|
||||
\\ \"--eval\", \"(vlime:main :port 52842)\" ]
|
||||
endfunction"))
|
||||
|
||||
;; Snippy
|
||||
(use! :dcampos/nvim-snippy
|
||||
:config
|
||||
@ -179,7 +153,6 @@
|
||||
:hrsh7th/cmp-path
|
||||
:hrsh7th/cmp-cmdline
|
||||
:hrsh7th/cmp-nvim-lsp
|
||||
:HiPhish/nvim-cmp-vlime
|
||||
{ 1 :ray-x/cmp-treesitter
|
||||
:after :nvim-cmp }
|
||||
:dcampos/cmp-snippy ]
|
||||
@ -207,44 +180,37 @@
|
||||
:config
|
||||
(setup! :guess-indent :auto_cmd true))
|
||||
|
||||
;; formatter
|
||||
(use! :mhartington/formatter.nvim
|
||||
:cmd [ :Format :FormatWrite ]
|
||||
:setup
|
||||
(bind! :n :<leader>o "<cmd>Format<cr>")
|
||||
(bind! :x :<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 [ "-" ]}) ]}))
|
||||
|
||||
;; lspconfig
|
||||
(use! :neovim/nvim-lspconfig
|
||||
:after :cmp-nvim-lsp
|
||||
:config
|
||||
(module-call! :plugin.lsp :configure))
|
||||
|
||||
(use! :jose-elias-alvarez/null-ls.nvim
|
||||
:after :nvim-lspconfig
|
||||
:config
|
||||
(let [builtins (. (require :null-ls) :builtins)]
|
||||
(setup! :null-ls
|
||||
: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" ]})
|
||||
])))
|
||||
|
||||
(use! :j-hui/fidget.nvim
|
||||
:after :nvim-lspconfig
|
||||
:config
|
||||
|
@ -21,8 +21,14 @@
|
||||
(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.server_capabilities.documentFormattingProvider
|
||||
; (bind! :n :<leader>o #(vim.lsp.buf.format { :async true }) 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 "v:lua.vim.lsp.formatexpr()")
|
||||
|
||||
;; Some telescope commands
|
||||
(bind! :n :<leader>s "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>" buf)
|
||||
@ -41,7 +47,6 @@
|
||||
(bind! :n :<leader>q "<cmd>TroubleToggle document_diagnostics<cr>")
|
||||
(bind! :n :<leader>Q "<cmd>TroubleToggle workspace_diagnostics<cr>"))
|
||||
|
||||
|
||||
(fn get-data-dir [server root]
|
||||
(let [resolved_path (vim.fn.resolve root)
|
||||
joined_path (vim.fn.substitute resolved_path "\\/" "@" :g)]
|
||||
@ -52,7 +57,7 @@
|
||||
|
||||
(fn configure []
|
||||
(let [lsp (require :lspconfig)
|
||||
configs (require :lspconfig.configs)
|
||||
;configs (require :lspconfig.configs)
|
||||
lsp-cap ((. (require :cmp_nvim_lsp) :default_capabilities))
|
||||
lsp-utils (require :plugin.lsp)]
|
||||
(macro setup-server! [name ...]
|
||||
@ -65,7 +70,20 @@
|
||||
(set last-key nil))
|
||||
(set last-key val)))
|
||||
`((. (. lsp ,name) :setup) ,opts)))
|
||||
(setup-server! :ccls)
|
||||
(setup-server! :clangd
|
||||
:on_attach (fn [client buf]
|
||||
(lsp-utils.on-attach client buf)
|
||||
(bind! :n :go :<cmd>ClangdSwitchSourceHeader<cr> buf))
|
||||
:cmd [ "clangd"
|
||||
"--header-insertion-decorators=0"
|
||||
"--background-index"
|
||||
"--clang-tidy"
|
||||
"--completion-style=bundled"
|
||||
"--function-arg-placeholders"
|
||||
"--header-insertion=never"
|
||||
"--malloc-trim"
|
||||
"--pch-storage=memory"
|
||||
"--offset-encoding=utf-16" ])
|
||||
(setup-server! :cmake)
|
||||
(setup-server! :gopls)
|
||||
(setup-server! :rust_analyzer)
|
||||
@ -83,20 +101,12 @@
|
||||
:library (vim.api.nvim_get_runtime_file "" true) }
|
||||
:telemetry {
|
||||
:enable false }}})
|
||||
(tset configs :fennel_language_server {
|
||||
:default_config {
|
||||
:cmd [ "fennel-language-server" ]
|
||||
:filetypes [ "fennel" ]
|
||||
:single_file_support true
|
||||
:root_dir (lsp.util.root_pattern "fnl")
|
||||
(setup-server! :fennel_language_server
|
||||
:settings {
|
||||
:fennel {
|
||||
:workspace {
|
||||
:library (vim.api.nvim_list_runtime_paths) }
|
||||
:diagnostics {
|
||||
:globals [ "vim" ] }}}}})
|
||||
; needed to make it not complain about a nil setup function
|
||||
(if configs.fennel_language_server.setup
|
||||
(setup-server! :fennel_language_server))))
|
||||
:globals [ "vim" ] }}})))
|
||||
|
||||
{ : configure : on-attach : get-data-dir }
|
||||
|
Reference in New Issue
Block a user