mirror of
https://github.com/stevenproctor/dotfiles.git
synced 2026-01-28 08:39:56 -06:00
nvim - replace aniseed.util fn-bridge with vim.api call
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
(module dotfiles.core {autoload {a aniseed.core}
|
||||
require {anenv aniseed.env
|
||||
nvim aniseed.nvim
|
||||
nu aniseed.nvim.util
|
||||
u dotfiles.util}})
|
||||
(module dotfiles.core
|
||||
{autoload {a aniseed.core}
|
||||
require {anenv aniseed.env nvim aniseed.nvim}})
|
||||
|
||||
(local u (require :dotfiles.util))
|
||||
|
||||
(nvim.ex.set :shortmess+=c)
|
||||
|
||||
@@ -10,86 +10,90 @@
|
||||
(nvim.ex.set :path+=**)
|
||||
(nvim.ex.set "wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*")
|
||||
|
||||
(defn- safe-source [filename]
|
||||
(let [glob (nvim.fn.glob filename)]
|
||||
(if (not (a.empty? glob))
|
||||
(nvim.ex.source filename))))
|
||||
(defn- safe-source
|
||||
[filename]
|
||||
(let [glob (nvim.fn.glob filename)]
|
||||
(if (not (a.empty? glob))
|
||||
(nvim.ex.source filename))))
|
||||
|
||||
; (a.map safe-source ["~/.vimrc" "~/.vimrc.local"])
|
||||
|
||||
(def- backup-dir (.. (nvim.fn.glob :$HOME) :/.vim/backup))
|
||||
(def- undo-dir (.. (nvim.fn.glob :$HOME) :/.vim/backup))
|
||||
|
||||
(def- on-opts [:autoindent
|
||||
:autoread
|
||||
:expandtab
|
||||
:exrc
|
||||
; allow project level (neo)vim files
|
||||
:hlsearch
|
||||
:ignorecase
|
||||
:incsearch
|
||||
:number
|
||||
:ruler
|
||||
:secure
|
||||
:shiftround
|
||||
; When at 3 spaces and I hit >>, go to 4, not 5.
|
||||
:showcmd
|
||||
; shows (parital) command in the status line
|
||||
:showmatch
|
||||
:smartcase
|
||||
:splitbelow
|
||||
:splitright
|
||||
:termguicolors
|
||||
:title
|
||||
:undofile
|
||||
:wildmenu])
|
||||
(def- on-opts
|
||||
[:autoindent
|
||||
:autoread
|
||||
:expandtab
|
||||
:exrc
|
||||
; allow project level (neo)vim files
|
||||
:hlsearch
|
||||
:ignorecase
|
||||
:incsearch
|
||||
:number
|
||||
:ruler
|
||||
:secure
|
||||
:shiftround
|
||||
; When at 3 spaces and I hit >>, go to 4, not 5.
|
||||
:showcmd
|
||||
; shows (parital) command in the status line
|
||||
:showmatch
|
||||
:smartcase
|
||||
:splitbelow
|
||||
:splitright
|
||||
:termguicolors
|
||||
:title
|
||||
:undofile
|
||||
:wildmenu])
|
||||
|
||||
(def- val-based-opts {; :t_Co 256
|
||||
:laststatus 2
|
||||
:encoding :utf-8
|
||||
:history 500
|
||||
:redrawtime 5000
|
||||
:scrolloff 3
|
||||
:guifont :Hasklig
|
||||
:guifontwide :Hasklig
|
||||
:background :dark
|
||||
:backupdir backup-dir
|
||||
:directory backup-dir
|
||||
;Don't clutter my dirs up with swp and tmp files
|
||||
:grepprg "ag --vimgrep"
|
||||
; Use Silver Searcher instead of grep
|
||||
:tags :tags
|
||||
:updatetime 300
|
||||
; per coc.vim for diagnostic messages
|
||||
:signcolumn "auto:1-3"
|
||||
:colorcolumn [81 100]
|
||||
:cmdheight 2
|
||||
; Better display for messages
|
||||
:undodir undo-dir
|
||||
:undolevels 1000
|
||||
:undoreload 10000
|
||||
:foldmethod :expr
|
||||
:foldexpr "nvim_treesitter#foldexpr()"
|
||||
:foldlevelstart 100
|
||||
:foldlevel 99
|
||||
:tabstop 2
|
||||
:shiftwidth 2
|
||||
:softtabstop 2
|
||||
:mouse ""
|
||||
:list true
|
||||
:listchars "tab:➥\\ ,trail:·,nbsp:■"
|
||||
:backspace "indent,eol,start"
|
||||
;allow backspacing over everything in insert mode
|
||||
:wildmode "list:longest,list:full"
|
||||
:wrap false})
|
||||
(def- val-based-opts
|
||||
{; :t_Co 256
|
||||
:laststatus 2
|
||||
:encoding :utf-8
|
||||
:history 500
|
||||
:redrawtime 5000
|
||||
:scrolloff 3
|
||||
:guifont :Hasklig
|
||||
:guifontwide :Hasklig
|
||||
:background :dark
|
||||
:backupdir backup-dir
|
||||
:directory backup-dir
|
||||
;Don't clutter my dirs up with swp and tmp files
|
||||
:grepprg "ag --vimgrep"
|
||||
; Use Silver Searcher instead of grep
|
||||
:tags :tags
|
||||
:updatetime 300
|
||||
; per coc.vim for diagnostic messages
|
||||
:signcolumn "auto:1-3"
|
||||
:colorcolumn [81 100]
|
||||
:cmdheight 2
|
||||
; Better display for messages
|
||||
:undodir undo-dir
|
||||
:undolevels 1000
|
||||
:undoreload 10000
|
||||
:foldmethod :expr
|
||||
:foldexpr "nvim_treesitter#foldexpr()"
|
||||
:foldlevelstart 100
|
||||
:foldlevel 99
|
||||
:tabstop 2
|
||||
:shiftwidth 2
|
||||
:softtabstop 2
|
||||
:mouse ""
|
||||
:list true
|
||||
:listchars "tab:➥\\ ,trail:·,nbsp:■"
|
||||
:backspace "indent,eol,start"
|
||||
;allow backspacing over everything in insert mode
|
||||
:wildmode "list:longest,list:full"
|
||||
:wrap false})
|
||||
|
||||
(def- append-val-opts {:diffopt "algorithm:patience"})
|
||||
|
||||
(defn- set-opt [[opt val]] (tset vim.opt (a.str opt) val))
|
||||
|
||||
(defn- set-opt+ [[opt val]]
|
||||
(let [existing-opt-val (a.get nvim.o opt)]
|
||||
(tset vim.opt (a.str opt) (a.str existing-opt-val "," val))))
|
||||
(defn- set-opt+
|
||||
[[opt val]]
|
||||
(let [existing-opt-val (a.get nvim.o opt)]
|
||||
(tset vim.opt (a.str opt) (a.str existing-opt-val "," val))))
|
||||
|
||||
(defn- set-opt-on [opt] (set-opt [opt true]))
|
||||
|
||||
@@ -109,15 +113,14 @@
|
||||
;
|
||||
; (nvim.fn.glob "~/.vimrc.local")
|
||||
|
||||
(defn make-fennel-scratch []
|
||||
(nvim.command "new | setlocal bt=nofile bh=wipe nobl noswapfile nu filetype=fennel"))
|
||||
(fn make-fennel-scratch []
|
||||
(vim.cmd "new | setlocal bt=nofile bh=wipe nobl noswapfile nu filetype=fennel"))
|
||||
|
||||
(nu.fn-bridge :FennelScratchBuffer :dotfiles.core :make-fennel-scratch
|
||||
{:return false})
|
||||
(vim.api.nvim_create_user_command :FennelScratchBuffer make-fennel-scratch {})
|
||||
|
||||
(u.nnoremap :<leader>fsb ":call FennelScratchBuffer ()<CR>")
|
||||
|
||||
(defn compile-fnl [] (print :recompiling)
|
||||
(anenv.init {:force true :init :dotfiles.init}))
|
||||
(fn compile-fnl [] (print :recompiling)
|
||||
(anenv.init {:force true :init :dotfiles.init}))
|
||||
|
||||
(nu.fn-bridge :AniseedCompile :dotfiles.core :compile-fnl {:return false})
|
||||
(vim.api.nvim_create_user_command :AniseedCompile compile-fnl {})
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
nvim aniseed.nvim
|
||||
lsp vim.lsp
|
||||
lspconfig lspconfig
|
||||
nu aniseed.nvim.util
|
||||
mason dotfiles.plugin.mason
|
||||
cmp_nvim_lsp cmp_nvim_lsp}})
|
||||
|
||||
@@ -14,139 +13,138 @@
|
||||
|
||||
(defn xbufmap [from to] (bufmap :x from to))
|
||||
|
||||
(vim.diagnostic.config
|
||||
{:signs {:text {vim.diagnostic.severity.ERROR "☢️"
|
||||
vim.diagnostic.severity.WARN "⚠️"
|
||||
vim.diagnostic.severity.INFO "ℹ️"
|
||||
vim.diagnostic.severity.HINT "🔎"}
|
||||
:linehl {vim.diagnostic.severity.ERROR :ErrorMsg}
|
||||
:numhl {vim.diagnostic.severity.WARN :WarningMsg}}})
|
||||
(vim.diagnostic.config {:signs {:text {vim.diagnostic.severity.ERROR "☢️"
|
||||
vim.diagnostic.severity.WARN "⚠️"
|
||||
vim.diagnostic.severity.INFO "ℹ️"
|
||||
vim.diagnostic.severity.HINT "🔎"}
|
||||
;; :linehl {vim.diagnostic.severity.ERROR :ErrorMsg}
|
||||
;; :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()"})
|
||||
{: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: '))"}})
|
||||
{: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 []]}})
|
||||
{: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 {})
|
||||
|
||||
(defn 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)]
|
||||
(when mappings
|
||||
(each [mapping cmd (pairs mappings)]
|
||||
(nbufmap mapping cmd)))
|
||||
(when command-lnmappings
|
||||
(each [lnmapping command-mapping (pairs command-lnmappings)]
|
||||
(let [lsp-cmd (a.first command-mapping)
|
||||
opts-str (accumulate [s "" i opt (ipairs (a.second command-mapping))]
|
||||
(.. s ", " opt))
|
||||
mapping (.. :<leader> lnmapping)
|
||||
cmd (.. "call LspExecuteCommand('" lsp-cmd "'" opts-str ")")]
|
||||
(nbufmap mapping cmd))))))
|
||||
(defn 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)]
|
||||
(when mappings
|
||||
(each [mapping cmd (pairs mappings)]
|
||||
(nbufmap mapping cmd)))
|
||||
(when command-lnmappings
|
||||
(each [lnmapping command-mapping (pairs command-lnmappings)]
|
||||
(let [lsp-cmd (a.first command-mapping)
|
||||
opts-str (accumulate [s "" i opt (ipairs (a.second command-mapping))]
|
||||
(.. s ", " opt))
|
||||
mapping (.. :<leader> lnmapping)
|
||||
cmd (.. "call LspExecuteCommand('" lsp-cmd "'" opts-str ")")]
|
||||
(nbufmap mapping cmd))))))
|
||||
|
||||
(defn 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)
|
||||
; -- 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', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
; -- buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<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>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
; -- buf_set_keymap('n', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
; -- buf_set_keymap('x', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
(nvim.buf_set_option 0 :omnifunc "v:lua.vim.lsp.omnifunc")
|
||||
(bind-client-mappings client)
|
||||
(if client.server_capabilities.documentFormattingProvider
|
||||
(nvim.ex.autocmd :BufWritePre :<buffer> ":lua vim.lsp.buf.format()"))
|
||||
; (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."))
|
||||
(defn 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)
|
||||
; -- 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', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
; -- buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<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>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
; -- buf_set_keymap('n', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
; -- buf_set_keymap('x', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
(nvim.buf_set_option 0 :omnifunc "v:lua.vim.lsp.omnifunc")
|
||||
(bind-client-mappings client)
|
||||
(if client.server_capabilities.documentFormattingProvider
|
||||
(nvim.ex.autocmd :BufWritePre :<buffer> ":lua vim.lsp.buf.format()")) ; (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."))
|
||||
|
||||
(def base-server-opts
|
||||
(let [capabilities (cmp_nvim_lsp.default_capabilities (lsp.protocol.make_client_capabilities))]
|
||||
{: on_attach : capabilities :flags {:debounce_text_changes 150}}))
|
||||
(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]
|
||||
(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 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 ...]
|
||||
(let [buf-uri (vim.uri_from_bufnr 0)
|
||||
cursor (vim.api.nvim_win_get_cursor 0)
|
||||
r (- (a.first cursor) 1)
|
||||
c (a.second cursor)
|
||||
opts [buf-uri r c]
|
||||
args (a.concat opts [...])]
|
||||
(vim.lsp.buf.execute_command {:command cmd :arguments args})))
|
||||
(defn 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)
|
||||
c (a.second cursor)
|
||||
opts [buf-uri r c]
|
||||
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}))
|
||||
(when-let [mason-lspconfig (require :mason-lspconfig)] (mason-lspconfig.setup)
|
||||
(mason-lspconfig.setup_handlers {1 default-server-handler}))
|
||||
|
||||
(u.nnoremap :<leader>li :LspInfo)
|
||||
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig
|
||||
:lsp-execute-command {:return false})
|
||||
|
||||
(vim.api.nvim_create_user_command :LspExecuteCommand lsp-execute-command {})
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
(module dotfiles.toggleterm
|
||||
{autoload {a aniseed.core}
|
||||
require {nvim aniseed.nvim
|
||||
nu aniseed.nvim.util
|
||||
toggleterm toggleterm}})
|
||||
(local toggleterm (require :toggleterm))
|
||||
|
||||
(toggleterm.setup {
|
||||
:open_mapping :<c-\>
|
||||
:start_in_insert true
|
||||
:insert_mappings true ;; whether or not the open mapping applies in insert mode
|
||||
:terminal_mappings true ;; whether or not the open mapping applies in the opened terminals
|
||||
:persist_size true
|
||||
:persist_mode true ;; if set to true (default) the previous terminal mode will be remembered
|
||||
:autochdir true
|
||||
})
|
||||
(toggleterm.setup {:open_mapping "<c-\\>"
|
||||
:start_in_insert true
|
||||
:insert_mappings true
|
||||
;; whether or not the open mapping applies in insert mode
|
||||
:terminal_mappings true
|
||||
;; whether or not the open mapping applies in the opened terminals
|
||||
:persist_size true
|
||||
:persist_mode true
|
||||
;; if set to true (default) the previous terminal mode will be remembered
|
||||
:autochdir true})
|
||||
|
||||
|
||||
(defn set_terminal_keymaps []
|
||||
(vim.keymap.set :t :<esc> :<C-\><C-n>)
|
||||
(vim.keymap.set :t :jk :<C-\><C-n>)
|
||||
(fn set-terminal-keymaps []
|
||||
(vim.keymap.set :t :<esc> "<C-\\><C-n>")
|
||||
(vim.keymap.set :t :jk "<C-\\><C-n>")
|
||||
(vim.keymap.set :t :<C-h> "<Cmd>wincmd h<CR>")
|
||||
(vim.keymap.set :t :<C-j> "<Cmd>wincmd j<CR>")
|
||||
(vim.keymap.set :t :<C-k> "<Cmd>wincmd k<CR>")
|
||||
(vim.keymap.set :t :<C-l> "<Cmd>wincmd l<CR>")
|
||||
(vim.keymap.set :t :<C-w> :<C-\><C-n><C-w>))
|
||||
(vim.keymap.set :t :<C-w> "<C-\\><C-n><C-w>"))
|
||||
|
||||
(vim.api.nvim_create_user_command :SetTerminalKeymaps set-terminal-keymaps {})
|
||||
|
||||
(nu.fn-bridge :SetTerminalKeymaps :dotfiles.toggleterm :set_terminal_keymaps {:return false})
|
||||
|
||||
(nvim.ex.autocmd :TermOpen "term://*" :call "SetTerminalKeymaps()")
|
||||
(vim.api.nvim_create_autocmd [:TermOpen]
|
||||
{:pattern "term://*"
|
||||
:callback set-terminal-keymaps})
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
(module dotfiles.plugin.treesitter
|
||||
{autoload {treesitter nvim-treesitter
|
||||
ts_utils nvim-treesitter.ts_utils
|
||||
treesitter-configs nvim-treesitter.configs}})
|
||||
(local treesitter-configs (require :nvim-treesitter.configs))
|
||||
|
||||
(treesitter-configs.setup
|
||||
{:highlight {:enable true
|
||||
;; :additional_vim_regex_highlighting false
|
||||
:additional_vim_regex_highlighting [:org]
|
||||
}
|
||||
|
||||
:ensure_installed :all ; [:org]
|
||||
|
||||
:rainbow {:enable true
|
||||
:extended_mode true ; Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
|
||||
:max_file_lines 10000 ; Do not enable for files with more than 1000 lines, int
|
||||
:colors [
|
||||
:#dc322f ; red
|
||||
:#b58900 ; yellow
|
||||
:#d33682 ; magenta
|
||||
:#859900 ; green
|
||||
:#2aa198 ; cyan
|
||||
:#268bd2 ; blue
|
||||
:#6c71c4 ; violet / brmagenta
|
||||
] ; table of hex strings
|
||||
}
|
||||
})
|
||||
(treesitter-configs.setup {:highlight {:enable true
|
||||
;; :additional_vim_regex_highlighting false
|
||||
:additional_vim_regex_highlighting [:org]}
|
||||
:ensure_installed :all
|
||||
; [:org]
|
||||
:rainbow {:enable true
|
||||
:extended_mode true
|
||||
; Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
|
||||
:max_file_lines 10000
|
||||
; Do not enable for files with more than 1000 lines, int
|
||||
:colors ["#dc322f"
|
||||
; red
|
||||
"#b58900"
|
||||
; yellow
|
||||
"#d33682"
|
||||
; magenta
|
||||
"#859900"
|
||||
; green
|
||||
"#2aa198"
|
||||
; cyan
|
||||
"#268bd2"
|
||||
; blue
|
||||
"#6c71c4"
|
||||
; violet / brmagenta
|
||||
]
|
||||
; table of hex strings
|
||||
}})
|
||||
|
||||
; lua print(require('nvim-treesitter.parsers').get_parser():language_for_range({ require('nvim-treesitter.ts_utils').get_node_at_cursor():range() }):lang())
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
(module dotfiles.terraform-helpers
|
||||
{autoload {a aniseed.core}
|
||||
require {anenv aniseed.env
|
||||
nvim aniseed.nvim
|
||||
nu aniseed.nvim.util
|
||||
u dotfiles.util}})
|
||||
require {anenv aniseed.env nvim aniseed.nvim u dotfiles.util}})
|
||||
|
||||
(defn append-to-buf [bufno lines]
|
||||
(when lines
|
||||
(nvim.buf_set_lines buffno -1 -1 false lines)))
|
||||
(fn append-to-buf [bufno lines]
|
||||
(when lines
|
||||
(nvim.buf_set_lines buffno -1 -1 false lines)))
|
||||
|
||||
(var tf-log-bufno nil)
|
||||
(defn tf-log-buffer [])
|
||||
|
||||
(defn terraform-import []
|
||||
(vim.fn.jobstart [:terraform :import :-no-color address id]
|
||||
{:stdout_buffered true
|
||||
:on_stdout (fn [_ data]
|
||||
(append-to-buf bufno data))}))
|
||||
(fn terraform-import []
|
||||
(vim.fn.jobstart [:terraform :import :-no-color address id]
|
||||
{:stdout_buffered true
|
||||
:on_stdout (fn [_ data]
|
||||
(append-to-buf bufno data))}))
|
||||
|
||||
; (nu.fn-bridge :ZoomToggle :dotfiles.zoom-toggle :zoom-toggle {:return false})
|
||||
; (u.nnoremap :<C-W>z ":call ZoomToggle()<CR>")
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
(module dotfiles.zoom-toggle
|
||||
{autoload {a aniseed.core}
|
||||
require {anenv aniseed.env
|
||||
nvim aniseed.nvim
|
||||
nu aniseed.nvim.util
|
||||
u dotfiles.util}})
|
||||
(local u (require :dotfiles.util))
|
||||
|
||||
(var unzoom! nil)
|
||||
|
||||
(defn zoom-toggle [] (if unzoom!
|
||||
(do
|
||||
(nvim.command unzoom!)
|
||||
(set unzoom! nil))
|
||||
(do
|
||||
(set unzoom! (nvim.fn.winrestcmd))
|
||||
(nvim.ex.resize)
|
||||
(nvim.ex.vertical :resize))))
|
||||
(fn zoom-toggle []
|
||||
(if unzoom!
|
||||
(do
|
||||
(vim.cmd unzoom!)
|
||||
(set unzoom! nil))
|
||||
(do
|
||||
(set unzoom! (vim.fn.winrestcmd))
|
||||
(vim.fn.resize)
|
||||
(vim.fn.vertical :resize))))
|
||||
|
||||
(vim.api.nvim_create_user_command :ZoomToggle zoom-toggle {})
|
||||
|
||||
(nu.fn-bridge :ZoomToggle :dotfiles.zoom-toggle :zoom-toggle {:return false})
|
||||
(u.nnoremap :<M-z> ":call ZoomToggle()<CR>")
|
||||
(u.tnoremap :<M-z> "<c-\\><c-n>:call ZoomToggle()<CR>")
|
||||
|
||||
Reference in New Issue
Block a user