Setup LSPInstall post install hook

This commit is contained in:
Proctor
2021-08-23 15:55:02 -05:00
parent 0ccd0bf6f7
commit ce141a383a

View File

@@ -29,23 +29,6 @@
(define-sign :Hint "🔎") (define-sign :Hint "🔎")
(define-sign :Information "") (define-sign :Information "")
(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)
args [buf-uri r c]
]
(vim.lsp.buf.execute_command {:command cmd
:arguments (a.merge args ...)})))
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig :lsp-execute-command {:return false})
; (nu.fn-bridge
; :DeleteHiddenBuffers
; :dotfiles.mapping :delete-hidden-buffers)
(def core-nmappings (def core-nmappings
{ {
:gd "lua vim.lsp.buf.definition()" :gd "lua vim.lsp.buf.definition()"
@@ -96,17 +79,28 @@
; -- buf_set_keymap('n', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<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) ; -- 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) (bind-client-mappings client)
(nvim.ex.autocmd :BufWritePre :<buffer> :lua "vim.lsp.buf.formatting_sync()") (nvim.ex.autocmd :BufWritePre :<buffer> :lua "vim.lsp.buf.formatting_sync()")
; -- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
; 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(0), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]] ; -- 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(0), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]]
(print "LSP Client Attached."); (print "LSP Client Attached."))
)
(let [lspi (require :lspinstall)] (let [lspi (require :lspinstall)]
(when lspi (when lspi
(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)
args [buf-uri r c]
]
(vim.lsp.buf.execute_command {:command cmd
:arguments (a.merge args ...)})))
(defn setup-servers [] (defn setup-servers []
(lspi.setup) (lspi.setup)
(let [lspconfig (require :lspconfig) (let [lspconfig (require :lspconfig)
@@ -114,60 +108,13 @@
(each [_ server (pairs servers)] (each [_ server (pairs servers)]
((. lspconfig server :setup) {:on_attach on_attach :flags {:debounce_text_changes 150} })))) ((. lspconfig server :setup) {:on_attach on_attach :flags {:debounce_text_changes 150} }))))
(defn on-post-install []
(setup-servers)
(nvim.ex.bufdo :e))
(setup-servers) (setup-servers)
(set lspi.post_install_hook on-post-install)
(nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig :lsp-execute-command {:return false})
(u.nnoremap :<leader>li "LspInfo"))) (u.nnoremap :<leader>li "LspInfo")))
; ()lspi.post_install_hook = post_lsp_install
; -- require'lspinstall'.post_install_hook = function ()
; -- setup_servers() -- reload installed servers
; -- vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
; -- end
; -- local nvim_lsp = require('lspconfig')
; --
; -- -- Use an on_attach function to only map the following keys
; -- -- after the language server attaches to the current buffer
; -- local on_attach = function(client, bufnr)
; -- local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
; -- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
; --
; -- --Enable completion triggered by <c-x><c-o>
; -- buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
; --
; -- -- Mappings.
; -- local opts = { noremap=true, silent=true }
; --
; -- -- See `:help vim.lsp.*` for documentation on any of the below functions
; --
; --
; -- -- 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(0), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]]
; --
; -- vim.api.nvim_command[[lua print("Lsp Client Attached.")]]
; -- end
; --
; --
; -- -- vim.api.nvim_set_keymap('n', '<leader>li', '<Cmd>LspInfo<CR>', { noremap=true, silent=true })
; --
; --
; -- local function setup_servers()
; -- require'lspinstall'.setup()
; -- local servers = require'lspinstall'.installed_servers()
; -- for _, server in pairs(servers) do
; -- require'lspconfig'[server].setup{
; -- on_attach = on_attach,
; -- flags = {
; -- debounce_text_changes = 150,
; -- }
; -- }
; -- end
; -- end
; --
; -- setup_servers()
; --
; -- -- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
; -- require'lspinstall'.post_install_hook = function ()
; -- setup_servers() -- reload installed servers
; -- vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
; -- end