Added null-fs

This commit is contained in:
2023-04-21 18:37:24 -07:00
parent d37c20404d
commit 198ad1377f
3 changed files with 68 additions and 87 deletions

View File

@ -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")
: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))))
(setup-server! :fennel_language_server
:settings {
:fennel {
:workspace {
:library (vim.api.nvim_list_runtime_paths) }
:diagnostics {
:globals [ "vim" ] }}})))
{ : configure : on-attach : get-data-dir }