mirror of
https://github.com/stevenproctor/dotfiles.git
synced 2026-01-28 14:19:55 -06:00
add null-ls language server
This commit is contained in:
@@ -1,178 +1,156 @@
|
|||||||
(module dotfiles.plugin.lspconfig
|
(module dotfiles.plugin.lspconfig
|
||||||
{autoload
|
{autoload {a aniseed.core
|
||||||
{a aniseed.core
|
u dotfiles.util
|
||||||
u dotfiles.util
|
nvim aniseed.nvim
|
||||||
nvim aniseed.nvim
|
nu aniseed.nvim.util}})
|
||||||
nu aniseed.nvim.util}})
|
|
||||||
|
|
||||||
(defn bufmap [mode from to]
|
(defn bufmap [mode from to] (u.noremap mode from to {:local? true}))
|
||||||
(u.noremap mode from to {:local? true}))
|
|
||||||
|
|
||||||
(defn nbufmap [from to]
|
(defn nbufmap [from to] (bufmap :n from to))
|
||||||
(bufmap :n from to))
|
|
||||||
|
|
||||||
(defn xbufmap [from to]
|
|
||||||
(bufmap :x from to))
|
|
||||||
|
|
||||||
|
(defn xbufmap [from to] (bufmap :x from to))
|
||||||
|
|
||||||
(defn define-sign [level sign]
|
(defn define-sign [level sign]
|
||||||
(let [sign-level (.. "DiagnosticSign" level)]
|
(let [sign-level (.. :DiagnosticSign level)]
|
||||||
(nvim.fn.sign_define sign-level
|
(nvim.fn.sign_define sign-level
|
||||||
{:texthl sign-level
|
{:texthl sign-level :text sign :numhl sign-level})))
|
||||||
:text sign
|
|
||||||
:numhl sign-level})))
|
|
||||||
|
|
||||||
; (define-sign :Error "☢️")
|
; (define-sign :Error "☢️")
|
||||||
; (define-sign :Warn "⚠️")
|
; (define-sign :Warn "⚠️")
|
||||||
; (define-sign :SignHint "🔎")
|
; (define-sign :SignHint "🔎")
|
||||||
; (define-sign :Info "ℹ️")
|
; (define-sign :Info "ℹ️")
|
||||||
(define-sign :Error "X")
|
(define-sign :Error :X)
|
||||||
(define-sign :Warn "!")
|
(define-sign :Warn "!")
|
||||||
(define-sign :SignHint "?")
|
(define-sign :SignHint "?")
|
||||||
(define-sign :Info "i")
|
(define-sign :Info :i)
|
||||||
|
|
||||||
(def core-nmappings
|
(def core-nmappings
|
||||||
{
|
{:gd "lua vim.lsp.buf.definition()"
|
||||||
:gd "lua vim.lsp.buf.definition()"
|
:gD "lua vim.lsp.buf.declaration()"
|
||||||
:gD "lua vim.lsp.buf.declaration()"
|
:gi "lua vim.lsp.buf.implementation()"
|
||||||
:gi "lua vim.lsp.buf.implementation()"
|
:gr "lua vim.lsp.buf.references()"
|
||||||
:gr "lua vim.lsp.buf.references()"
|
:K "lua vim.lsp.buf.hover()"
|
||||||
:K "lua vim.lsp.buf.hover()"
|
"[g" "lua vim.diagnostic.goto_prev()"
|
||||||
"[g" "lua vim.diagnostic.goto_prev()"
|
"]g" "lua vim.diagnostic.goto_next()"
|
||||||
"]g" "lua vim.diagnostic.goto_next()"
|
:<c-k> "lua vim.lsp.buf.signature_help()"
|
||||||
:<c-k> "lua vim.lsp.buf.signature_help()"
|
:<leader>ca "lua vim.lsp.buf.code_action()"
|
||||||
:<leader>ca "lua vim.lsp.buf.code_action()"
|
:<leader>cl "lua vim.lsp.codelens.run()"
|
||||||
:<leader>cl "lua vim.lsp.codelens.run()"
|
:<leader>ic "lua vim.lsp.buf.incoming_calls()"
|
||||||
:<leader>ic "lua vim.lsp.buf.incoming_calls()"
|
;; TODO: think of new mapping; conficts with org mode
|
||||||
;; TODO: think of new mapping; conficts with org mode
|
;; :<leader>oc "lua vim.lsp.buf.outgoing_calls()"
|
||||||
;; :<leader>oc "lua vim.lsp.buf.outgoing_calls()"
|
:<leader>sld "lua vim.diagnostic.open_float(nil, {source = 'always'})"
|
||||||
:<leader>sld "lua vim.diagnostic.open_float(nil, {source = 'always'})"
|
:<leader>rn "lua vim.lsp.buf.rename()"
|
||||||
:<leader>rn "lua vim.lsp.buf.rename()"
|
:<leader>fa "lua vim.lsp.buf.format()"})
|
||||||
:<leader>fa "lua vim.lsp.buf.formatting_sync()"
|
|
||||||
})
|
|
||||||
|
|
||||||
(def client-nmappings
|
(def client-nmappings
|
||||||
{:clojure_lsp
|
{:clojure_lsp {:<leader>cn "call LspExecuteCommand('clean-ns')"
|
||||||
{
|
:<leader>ref "call LspExecuteCommand('extract-function', input('Function name: '))"
|
||||||
:<leader>cn "call LspExecuteCommand('clean-ns')"
|
:<leader>id "call LspExecuteCommand('inline-symbol')"
|
||||||
:<leader>ref "call LspExecuteCommand('extract-function', input('Function name: '))"
|
:<leader>il "call LspExecuteCommand('introduce-let', input('Binding name: '))"
|
||||||
:<leader>id "call LspExecuteCommand('inline-symbol')"
|
:<leader>m2l "call LspExecuteCommand('move-to-let', input('Binding name: '))"}})
|
||||||
:<leader>il "call LspExecuteCommand('introduce-let', input('Binding name: '))"
|
|
||||||
:<leader>m2l "call LspExecuteCommand('move-to-let', input('Binding name: '))"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
(def client-command-lnmappings
|
(def client-command-lnmappings
|
||||||
{:clojure_lsp
|
{:clojure_lsp {:ai [:add-import-to-namespace
|
||||||
{:ai [:add-import-to-namespace ["input('Namespace name: ')"]]
|
["input('Namespace name: ')"]]
|
||||||
:am [:add-missing-libspec []]
|
:am [:add-missing-libspec []]
|
||||||
:as [:add-require-suggestion ["input('Namespace name: ')" "input('Namespace as: ')" "input('Namespace name: ')"]]
|
:as [:add-require-suggestion
|
||||||
:cc [:cycle-coll []]
|
["input('Namespace name: ')"
|
||||||
:cn [:clean-ns []]
|
"input('Namespace as: ')"
|
||||||
:cp [:cycle-privacy []]
|
"input('Namespace name: ')"]]
|
||||||
:ct [:create-test []]
|
:cc [:cycle-coll []]
|
||||||
:df [:demote-fn []]
|
:cn [:clean-ns []]
|
||||||
:db [:drag-backward []]
|
:cp [:cycle-privacy []]
|
||||||
:df [:drag-forward []]
|
:ct [:create-test []]
|
||||||
:dk [:destructure-keys []]
|
:df [:drag-forward []]
|
||||||
:ed [:extract-to-def ["input('Definition name: ')"]]
|
:db [:drag-backward []]
|
||||||
:ef [:extract-function ["input('Function name: ')"]]
|
:df [:drag-forward []]
|
||||||
:el [:expand-let []]
|
:dk [:destructure-keys []]
|
||||||
:fe [:create-function []]
|
:ed [:extract-to-def ["input('Definition name: ')"]]
|
||||||
:il [:introduce-let ["input('Binding name: ')"]]
|
:ef [:extract-function ["input('Function name: ')"]]
|
||||||
:is [:inline-symbol []]
|
:el [:expand-let []]
|
||||||
:ma [:resolve-macro-as []]
|
:fe [:create-function []]
|
||||||
:mf [:move-form ["input('File name: ')"]]
|
:il [:introduce-let ["input('Binding name: ')"]]
|
||||||
:ml [:move-to-let ["input('Binding name: ')"]]
|
:is [:inline-symbol []]
|
||||||
:pf [:promote-fn ["input('Function name: ')"]]
|
:ma [:resolve-macro-as []]
|
||||||
:sc [:change-collection ["input('Collection type: ')"]]
|
:mf [:move-form ["input('File name: ')"]]
|
||||||
:sm [:sort-map []]
|
:ml [:move-to-let ["input('Binding name: ')"]]
|
||||||
:tf [:thread-first-all []]
|
:pf [:promote-fn ["input('Function name: ')"]]
|
||||||
:tF [:thread-first []]
|
:sc [:change-collection ["input('Collection type: ')"]]
|
||||||
:tl [:thread-last-all []]
|
:sm [:sort-map []]
|
||||||
:tL [:thread-last []]
|
:tf [:thread-first-all []]
|
||||||
:ua [:unwind-all []]
|
:tF [:thread-first []]
|
||||||
:uw [:unwind-thread []]
|
:tl [:thread-last-all []]
|
||||||
}
|
:tL [:thread-last []]
|
||||||
})
|
:ua [:unwind-all []]
|
||||||
|
:uw [:unwind-thread []]}})
|
||||||
|
|
||||||
(defn bind-client-mappings [client]
|
(defn bind-client-mappings [client]
|
||||||
(let [client-name (a.get client :name)
|
(let [client-name (a.get client :name)
|
||||||
mappings (a.get client-nmappings client-name)
|
mappings (a.get client-nmappings client-name)
|
||||||
command-lnmappings (a.get client-command-lnmappings client-name)]
|
command-lnmappings (a.get client-command-lnmappings client-name)]
|
||||||
(when mappings
|
(when mappings
|
||||||
(each [mapping cmd (pairs mappings)]
|
(each [mapping cmd (pairs mappings)]
|
||||||
(nbufmap mapping cmd)))
|
(nbufmap mapping cmd)))
|
||||||
(when command-lnmappings
|
(when command-lnmappings
|
||||||
(each [lnmapping command-mapping (pairs command-lnmappings)]
|
(each [lnmapping command-mapping (pairs command-lnmappings)]
|
||||||
(let [lsp-cmd (a.first command-mapping)
|
(let [lsp-cmd (a.first command-mapping)
|
||||||
opts-str (accumulate [s ""
|
opts-str (accumulate [s "" i opt (ipairs (a.second command-mapping))]
|
||||||
i opt (ipairs (a.second command-mapping))]
|
(.. s ", " opt))
|
||||||
(.. s ", " opt))
|
mapping (.. :<leader> lnmapping)
|
||||||
mapping (.. :<leader> lnmapping)
|
cmd (.. "call LspExecuteCommand('" lsp-cmd "'" opts-str ")")]
|
||||||
cmd (.. "call LspExecuteCommand('" lsp-cmd "'" opts-str ")")]
|
(nbufmap mapping cmd))))))
|
||||||
(nbufmap mapping cmd))))))
|
|
||||||
|
|
||||||
(defn on_attach [client bufnr]
|
(defn on_attach [client bufnr]
|
||||||
(each [mapping cmd (pairs core-nmappings)]
|
(each [mapping cmd (pairs core-nmappings)]
|
||||||
(nbufmap mapping cmd))
|
(nbufmap mapping cmd)) ; x mode mappings
|
||||||
|
(xbufmap :<leader>fa "lua vim.lsp.buf.format()")
|
||||||
; x mode mappings
|
; -- buf_set_keymap('n', 'gs', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
|
||||||
(xbufmap :<leader>fa "lua vim.lsp.buf.formatting_sync()")
|
; -- buf_set_keymap('n', 'gS', '<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
||||||
|
; -- buf_set_keymap('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
; -- buf_set_keymap('n', 'gs', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
|
; -- buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
; -- buf_set_keymap('n', 'gS', '<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
; -- buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
; -- buf_set_keymap('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
; -- buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
; -- buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
; -- buf_set_keymap('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
; -- buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
; -- buf_set_keymap('n', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||||
; -- buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
; -- buf_set_keymap('x', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||||
; -- buf_set_keymap('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
(nvim.buf_set_option 0 :omnifunc "v:lua.vim.lsp.omnifunc")
|
||||||
; -- buf_set_keymap('n', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
(bind-client-mappings client)
|
||||||
; -- buf_set_keymap('x', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
(nvim.ex.autocmd :BufWritePre :<buffer> :lua
|
||||||
|
"vim.lsp.buf.formatting_sync()")
|
||||||
(nvim.buf_set_option 0 :omnifunc "v:lua.vim.lsp.omnifunc")
|
; (nvim.ex.autocmd "BufEnter,CursorHold,InsertLeave" :<buffer> :lua "vim.lsp.codelens.refresh()")
|
||||||
|
; client autocmds
|
||||||
(bind-client-mappings client)
|
; -- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf_request_sync(vim.api.nvim_get_current_buf(), 'workspace/executeCommand', {command = 'clean-ns', arguments = {vim.uri_from_bufnr(1), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]]
|
||||||
(nvim.ex.autocmd :BufWritePre :<buffer> :lua "vim.lsp.buf.formatting_sync()")
|
(print "LSP Client Attached."))
|
||||||
; (nvim.ex.autocmd "BufEnter,CursorHold,InsertLeave" :<buffer> :lua "vim.lsp.codelens.refresh()")
|
|
||||||
|
|
||||||
; client autocmds
|
|
||||||
; -- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf_request_sync(vim.api.nvim_get_current_buf(), 'workspace/executeCommand', {command = 'clean-ns', arguments = {vim.uri_from_bufnr(1), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]]
|
|
||||||
|
|
||||||
(print "LSP Client Attached."))
|
|
||||||
|
|
||||||
(let [lspi (require :nvim-lsp-installer)]
|
(let [lspi (require :nvim-lsp-installer)]
|
||||||
(when lspi
|
(when lspi
|
||||||
|
|
||||||
(defn lsp-execute-command [cmd ...]
|
(defn lsp-execute-command [cmd ...]
|
||||||
(let [buf-uri (vim.uri_from_bufnr 0)
|
(let [buf-uri (vim.uri_from_bufnr 0)
|
||||||
cursor (vim.api.nvim_win_get_cursor 0)
|
cursor (vim.api.nvim_win_get_cursor 0)
|
||||||
r (- (a.first cursor) 1)
|
r (- (a.first cursor) 1)
|
||||||
c (a.second cursor)
|
c (a.second cursor)
|
||||||
opts [buf-uri r c]
|
opts [buf-uri r c]
|
||||||
args (a.concat opts [...])]
|
args (a.concat opts [...])]
|
||||||
(vim.lsp.buf.execute_command {:command cmd
|
(vim.lsp.buf.execute_command {:command cmd :arguments args})))
|
||||||
:arguments args})))
|
|
||||||
|
|
||||||
(defn setup-servers []
|
(defn setup-servers []
|
||||||
(lspi.on_server_ready (fn [server]
|
(lspi.on_server_ready (fn [server]
|
||||||
(let [opts {:on_attach on_attach :flags {:debounce_text_changes 150} }]
|
(let [opts {: on_attach
|
||||||
(server:setup opts))))
|
:flags {:debounce_text_changes 150}}]
|
||||||
;; (let [lspconfig (require :lspconfig)
|
(server:setup opts))))
|
||||||
;; servers (lspi.get_installed_servers)]
|
;; (let [lspconfig (require :lspconfig)
|
||||||
;; (each [_ server (pairs servers)]
|
;; servers (lspi.get_installed_servers)]
|
||||||
;; (server.setup {:on_attach on_attach :flags {:debounce_text_changes 150} })))
|
;; (each [_ server (pairs servers)]
|
||||||
)
|
;; (server.setup {:on_attach on_attach :flags {:debounce_text_changes 150} })))
|
||||||
|
)
|
||||||
(defn on-post-install []
|
(defn on-post-install [] (setup-servers) (nvim.ex.bufdo :e))
|
||||||
(setup-servers)
|
|
||||||
(nvim.ex.bufdo :e))
|
|
||||||
|
|
||||||
(setup-servers)
|
(setup-servers)
|
||||||
|
|
||||||
(set lspi.post_install_hook on-post-install)
|
(set lspi.post_install_hook on-post-install)
|
||||||
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig :lsp-execute-command {:return false})
|
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig
|
||||||
|
:lsp-execute-command {:return false})
|
||||||
|
(u.nnoremap :<leader>li :LspInfo)))
|
||||||
|
|
||||||
(u.nnoremap :<leader>li "LspInfo")))
|
(comment (let [lspi (require :nvim-lsp-installer)
|
||||||
|
;lspconfig (require :lspconfig)
|
||||||
|
servers (lspi.get_installed_servers)]
|
||||||
|
(each [_ server (pairs servers)]
|
||||||
|
(a.pr server))))
|
||||||
|
|||||||
13
nvim/.config/nvim/fnl/dotfiles/plugin/null-ls.fnl
Normal file
13
nvim/.config/nvim/fnl/dotfiles/plugin/null-ls.fnl
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
(module dotfiles.plugin.null-ls
|
||||||
|
{autoload {nvim aniseed.nvim
|
||||||
|
a aniseed.core
|
||||||
|
nu aniseed.nvim.util
|
||||||
|
null-ls null-ls
|
||||||
|
lspconfig dotfiles.plugin.lspconfig}})
|
||||||
|
|
||||||
|
(def null-ls-server-options
|
||||||
|
{:sources [null-ls.builtins.formatting.stylua
|
||||||
|
null-ls.builtins.formatting.fnlfmt]
|
||||||
|
:on_attach lspconfig.on_attach})
|
||||||
|
|
||||||
|
(null-ls.setup null-ls-server-options)
|
||||||
@@ -50,6 +50,8 @@
|
|||||||
:hrsh7th/vim-vsnip-integ {}
|
:hrsh7th/vim-vsnip-integ {}
|
||||||
:Iron-E/nvim-soluarized {}
|
:Iron-E/nvim-soluarized {}
|
||||||
:jiangmiao/auto-pairs {} ; backets, parens, and quotes in pairs
|
:jiangmiao/auto-pairs {} ; backets, parens, and quotes in pairs
|
||||||
|
:jose-elias-alvarez/null-ls.nvim {:mod :null-ls
|
||||||
|
:requires [:nvim-lua/plenary.nvim]}
|
||||||
:junegunn/vim-easy-align {:mod :easyalign}
|
:junegunn/vim-easy-align {:mod :easyalign}
|
||||||
:kovisoft/paredit {:mod :paredit}
|
:kovisoft/paredit {:mod :paredit}
|
||||||
:kristijanhusak/vim-dadbod-completion {}
|
:kristijanhusak/vim-dadbod-completion {}
|
||||||
|
|||||||
Reference in New Issue
Block a user