mirror of
https://github.com/stevenproctor/dotfiles.git
synced 2026-01-28 08:39:56 -06:00
nvim - more refactor away from aniseed to pure fennel
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
(module dotfiles.plugin.compe {autoload {nvim aniseed.nvim}})
|
||||
|
||||
(set vim.o.completeopt "menuone,noselect")
|
||||
|
||||
(let [compe (require :compe)]
|
||||
(when compe
|
||||
(compe.setup {:enabled true
|
||||
:autocomplete true
|
||||
:debug false
|
||||
:min_length 1
|
||||
:preselect :enable
|
||||
:throttle_time 80
|
||||
:source_timeout 200
|
||||
:incomplete_delay 400
|
||||
:max_abbr_width 100
|
||||
:max_kind_width 100
|
||||
:max_menu_width 100
|
||||
:documentation true
|
||||
:source {:path true
|
||||
:buffer true
|
||||
:calc true
|
||||
:emoji true
|
||||
:nvim_lsp true
|
||||
:nvim_lua true
|
||||
:conjure true
|
||||
:orgmode true
|
||||
:vsnip true
|
||||
:vim_dadbod_completion true}})))
|
||||
|
||||
(nvim.ex.inoremap "<silent><expr> <C-Space> compe#complete()")
|
||||
(nvim.ex.inoremap "<silent><expr> <CR> compe#confirm('<CR>')")
|
||||
(nvim.ex.inoremap "<silent><expr> <C-e> compe#close('<C-e>')")
|
||||
(nvim.ex.inoremap "<silent><expr> <C-f> compe#scroll({ 'delta': +4 })")
|
||||
(nvim.ex.inoremap "<silent><expr> <C-d> compe#scroll({ 'delta': -4 })")
|
||||
@@ -4,14 +4,13 @@
|
||||
nvim aniseed.nvim
|
||||
lsp vim.lsp
|
||||
lspconfig lspconfig
|
||||
mason dotfiles.plugin.mason
|
||||
cmp_nvim_lsp cmp_nvim_lsp}})
|
||||
|
||||
(defn bufmap [mode from to] (u.noremap mode from to {:local? true}))
|
||||
(fn bufmap [mode from to] (u.noremap mode from to {:local? true}))
|
||||
|
||||
(defn nbufmap [from to] (bufmap :n from to))
|
||||
(fn nbufmap [from to] (bufmap :n from to))
|
||||
|
||||
(defn xbufmap [from to] (bufmap :x from to))
|
||||
(fn xbufmap [from to] (bufmap :x from to))
|
||||
|
||||
(vim.diagnostic.config {:signs {:text {vim.diagnostic.severity.ERROR "☢️"
|
||||
vim.diagnostic.severity.WARN "⚠️"
|
||||
@@ -21,69 +20,69 @@
|
||||
;; :numhl {vim.diagnostic.severity.WARN :WarningMsg}
|
||||
}})
|
||||
|
||||
(def core-nmappings
|
||||
{:gd "lua vim.lsp.buf.definition()"
|
||||
:gD "lua vim.lsp.buf.declaration()"
|
||||
:gi "lua vim.lsp.buf.implementation()"
|
||||
:gr "lua vim.lsp.buf.references()"
|
||||
:K "lua vim.lsp.buf.hover()"
|
||||
"[g" "lua vim.diagnostic.goto_prev()"
|
||||
"]g" "lua vim.diagnostic.goto_next()"
|
||||
;:<c-k> "lua vim.lsp.buf.signature_help()"
|
||||
:<leader>ca "lua vim.lsp.buf.code_action()"
|
||||
:<leader>cl "lua vim.lsp.codelens.run()"
|
||||
:<leader>ic "lua vim.lsp.buf.incoming_calls()"
|
||||
;; TODO: think of new mapping; conficts with org mode
|
||||
;; :<leader>oc "lua vim.lsp.buf.outgoing_calls()"
|
||||
:<leader>sld "lua vim.diagnostic.open_float(nil, {source = 'always'})"
|
||||
:<leader>rn "lua vim.lsp.buf.rename()"
|
||||
:<leader>fa "lua vim.lsp.buf.format()"})
|
||||
(local core-nmappings
|
||||
{:gd "lua vim.lsp.buf.definition()"
|
||||
:gD "lua vim.lsp.buf.declaration()"
|
||||
:gi "lua vim.lsp.buf.implementation()"
|
||||
:gr "lua vim.lsp.buf.references()"
|
||||
:K "lua vim.lsp.buf.hover()"
|
||||
"[g" "lua vim.diagnostic.goto_prev()"
|
||||
"]g" "lua vim.diagnostic.goto_next()"
|
||||
;:<c-k> "lua vim.lsp.buf.signature_help()"
|
||||
:<leader>ca "lua vim.lsp.buf.code_action()"
|
||||
:<leader>cl "lua vim.lsp.codelens.run()"
|
||||
:<leader>ic "lua vim.lsp.buf.incoming_calls()"
|
||||
;; TODO: think of new mapping; conficts with org mode
|
||||
;; :<leader>oc "lua vim.lsp.buf.outgoing_calls()"
|
||||
:<leader>sld "lua vim.diagnostic.open_float(nil, {source = 'always'})"
|
||||
:<leader>rn "lua vim.lsp.buf.rename()"
|
||||
:<leader>fa "lua vim.lsp.buf.format()"})
|
||||
|
||||
(def client-nmappings
|
||||
{:clojure_lsp {:<leader>cn "call LspExecuteCommand('clean-ns')"
|
||||
:<leader>ref "call LspExecuteCommand('extract-function', input('Function name: '))"
|
||||
:<leader>id "call LspExecuteCommand('inline-symbol')"
|
||||
:<leader>il "call LspExecuteCommand('introduce-let', input('Binding name: '))"
|
||||
:<leader>m2l "call LspExecuteCommand('move-to-let', input('Binding name: '))"}})
|
||||
(local client-nmappings
|
||||
{:clojure_lsp {:<leader>cn "call LspExecuteCommand('clean-ns')"
|
||||
:<leader>ref "call LspExecuteCommand('extract-function', input('Function name: '))"
|
||||
:<leader>id "call LspExecuteCommand('inline-symbol')"
|
||||
:<leader>il "call LspExecuteCommand('introduce-let', input('Binding name: '))"
|
||||
:<leader>m2l "call LspExecuteCommand('move-to-let', input('Binding name: '))"}})
|
||||
|
||||
(def client-command-lnmappings
|
||||
{:clojure_lsp {:ai [:add-import-to-namespace ["input('Namespace name: ')"]]
|
||||
:am [:add-missing-libspec []]
|
||||
:as [:add-require-suggestion
|
||||
["input('Namespace name: ')"
|
||||
"input('Namespace as: ')"
|
||||
"input('Namespace name: ')"]]
|
||||
:cc [:cycle-coll []]
|
||||
:cn [:clean-ns []]
|
||||
:cp [:cycle-privacy []]
|
||||
:ct [:create-test []]
|
||||
:df [:drag-forward []]
|
||||
:db [:drag-backward []]
|
||||
:df [:drag-forward []]
|
||||
:dk [:destructure-keys []]
|
||||
:ed [:extract-to-def ["input('Definition name: ')"]]
|
||||
:ef [:extract-function ["input('Function name: ')"]]
|
||||
:el [:expand-let []]
|
||||
:fe [:create-function []]
|
||||
:il [:introduce-let ["input('Binding name: ')"]]
|
||||
:is [:inline-symbol []]
|
||||
:ma [:resolve-macro-as []]
|
||||
:mf [:move-form ["input('File name: ')"]]
|
||||
:ml [:move-to-let ["input('Binding name: ')"]]
|
||||
:pf [:promote-fn ["input('Function name: ')"]]
|
||||
:sc [:change-collection ["input('Collection type: ')"]]
|
||||
:sm [:sort-map []]
|
||||
:tf [:thread-first-all []]
|
||||
:tF [:thread-first []]
|
||||
:tl [:thread-last-all []]
|
||||
:tL [:thread-last []]
|
||||
:ua [:unwind-all []]
|
||||
:uw [:unwind-thread []]}})
|
||||
(local client-command-lnmappings
|
||||
{:clojure_lsp {:ai [:add-import-to-namespace
|
||||
["input('Namespace name: ')"]]
|
||||
:am [:add-missing-libspec []]
|
||||
:as [:add-require-suggestion
|
||||
["input('Namespace name: ')"
|
||||
"input('Namespace as: ')"
|
||||
"input('Namespace name: ')"]]
|
||||
:cc [:cycle-coll []]
|
||||
:cn [:clean-ns []]
|
||||
:cp [:cycle-privacy []]
|
||||
:ct [:create-test []]
|
||||
:df [:drag-forward []]
|
||||
:db [:drag-backward []]
|
||||
:df [:drag-forward []]
|
||||
:dk [:destructure-keys []]
|
||||
:ed [:extract-to-def ["input('Definition name: ')"]]
|
||||
:ef [:extract-function ["input('Function name: ')"]]
|
||||
:el [:expand-let []]
|
||||
:fe [:create-function []]
|
||||
:il [:introduce-let ["input('Binding name: ')"]]
|
||||
:is [:inline-symbol []]
|
||||
:ma [:resolve-macro-as []]
|
||||
:mf [:move-form ["input('File name: ')"]]
|
||||
:ml [:move-to-let ["input('Binding name: ')"]]
|
||||
:pf [:promote-fn ["input('Function name: ')"]]
|
||||
:sc [:change-collection ["input('Collection type: ')"]]
|
||||
:sm [:sort-map []]
|
||||
:tf [:thread-first-all []]
|
||||
:tF [:thread-first []]
|
||||
:tl [:thread-last-all []]
|
||||
:tL [:thread-last []]
|
||||
:ua [:unwind-all []]
|
||||
:uw [:unwind-thread []]}})
|
||||
|
||||
(def server-specific-opts {})
|
||||
(local server-specific-opts {})
|
||||
|
||||
(defn bind-client-mappings
|
||||
[client]
|
||||
(fn bind-client-mappings [client]
|
||||
(let [client-name (a.get client :name)
|
||||
mappings (a.get client-nmappings client-name)
|
||||
command-lnmappings (a.get client-command-lnmappings client-name)]
|
||||
@@ -99,8 +98,7 @@
|
||||
cmd (.. "call LspExecuteCommand('" lsp-cmd "'" opts-str ")")]
|
||||
(nbufmap mapping cmd))))))
|
||||
|
||||
(defn on_attach
|
||||
[client bufnr]
|
||||
(fn on_attach [client bufnr]
|
||||
(each [mapping cmd (pairs core-nmappings)]
|
||||
(nbufmap mapping cmd)) ; x mode mappings
|
||||
(xbufmap :<leader>fa "lua vim.lsp.buf.format()") ; -- buf_set_keymap('n', 'gs', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
|
||||
@@ -119,19 +117,17 @@
|
||||
; 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."))
|
||||
|
||||
(def base-server-opts
|
||||
(let [capabilities (cmp_nvim_lsp.default_capabilities (lsp.protocol.make_client_capabilities))]
|
||||
{: on_attach : capabilities :flags {:debounce_text_changes 150}}))
|
||||
(local base-server-opts
|
||||
(let [capabilities (cmp_nvim_lsp.default_capabilities (lsp.protocol.make_client_capabilities))]
|
||||
{: on_attach : capabilities :flags {:debounce_text_changes 150}}))
|
||||
|
||||
(defn default-server-handler
|
||||
[server-name]
|
||||
(fn default-server-handler [server-name]
|
||||
(let [specific-opts (a.get server-specific-opts server-name {})
|
||||
server (a.get lspconfig server-name)
|
||||
server-opts (a.merge base-server-opts server-opts)]
|
||||
(server.setup server-opts)))
|
||||
|
||||
(defn lsp-execute-command
|
||||
[cmd ...]
|
||||
(fn lsp-execute-command [cmd ...]
|
||||
(let [buf-uri (vim.uri_from_bufnr 0)
|
||||
cursor (vim.api.nvim_win_get_cursor 0)
|
||||
r (- (a.first cursor) 1)
|
||||
@@ -140,11 +136,6 @@
|
||||
args (a.concat opts [...])]
|
||||
(vim.lsp.buf.execute_command {:command cmd :arguments args})))
|
||||
|
||||
(mason.setup)
|
||||
|
||||
(when-let [mason-lspconfig (require :mason-lspconfig)] (mason-lspconfig.setup)
|
||||
(mason-lspconfig.setup_handlers {1 default-server-handler}))
|
||||
|
||||
(u.nnoremap :<leader>li :LspInfo)
|
||||
|
||||
(vim.api.nvim_create_user_command :LspExecuteCommand lsp-execute-command {})
|
||||
|
||||
@@ -9,3 +9,8 @@
|
||||
(mason-lspconf.setup_handlers {1 lspconfig.default-server-handler})))))
|
||||
|
||||
(setup)
|
||||
;; (mason.setup)
|
||||
;;
|
||||
;; (when-let [mason-lspconfig (require :mason-lspconfig)]
|
||||
;; (mason-lspconfig.setup)
|
||||
;; (mason-lspconfig.setup_handlers {1 default-server-handler}))
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
(module dotfiles.plugin.telescope
|
||||
{autoload {nvim aniseed.nvim
|
||||
util dotfiles.util
|
||||
telescope telescope
|
||||
project-nvim project_nvim}})
|
||||
(local util (require :dotfiles.util))
|
||||
(local telescope (require :telescope))
|
||||
|
||||
(local vimgrep_arguments [:ag
|
||||
:--nocolor
|
||||
|
||||
Reference in New Issue
Block a user