commit 3fa32d654b20907b78342d991dd6d541a9db3b48
parent 3284d6d958ab402c8ccc332a4c64ff2ef3659b52
Author: Tomas Nemec <nemi@skaut.cz>
Date: Mon, 29 Nov 2021 10:11:23 +0100
update
Diffstat:
7 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/ftplugin/sh.lua b/ftplugin/sh.lua
@@ -1,3 +1,4 @@
vim.cmd [[comp bash]]
-require('cmp').setup.buffer {sources = {{name = 'nvim_lsp'}, {name = 'exe'}, {name = 'path'}}}
+local ok, cmp = pcall(require, 'cmp')
+if ok then cmp.setup.buffer {sources = {{name = 'nvim_lsp'}, {name = 'exe'}, {name = 'path'}}} end
diff --git a/ftplugin/zsh.lua b/ftplugin/zsh.lua
@@ -1,3 +1,4 @@
vim.cmd [[comp zsh]]
-require('cmp').setup.buffer {sources = {{name = 'nvim_lsp'}, {name = 'exe'}, {name = 'path'}}}
+local ok, cmp = pcall(require, 'cmp')
+if ok then cmp.setup.buffer {sources = {{name = 'nvim_lsp'}, {name = 'exe'}, {name = 'path'}}} end
diff --git a/init.lua b/init.lua
@@ -1,7 +1,7 @@
local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
- vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
+ vim.api.nvim_command('!git clone --depth=1 https://github.com/wbthomason/packer.nvim ' .. install_path)
end
function _G.dump(...)
@@ -10,8 +10,8 @@ function _G.dump(...)
end
-- Meta setup
-vim.cmd [[runtime plugin/astronauta.vim]]
require('impatient')
+vim.cmd [[runtime plugin/astronauta.vim]]
vim.g.mapleader = ','
require('colorbuddy').colorscheme('my-default')
@@ -161,9 +161,6 @@ nnoremap {'v.', 'V'}
nnoremap {'=.', '=='}
nnoremap {'gc.', 'gcc'}
--- plugins
-vim.g.user_emmet_leader_key = '<C-Z>'
-
-- autocommands
local au = require('tms.c.autocmd')
au.addListeners({
@@ -196,5 +193,4 @@ vim.cmd('command! Reload lua require("tms.u.reload").nvim()')
-- ]], false)
vim.cmd [[ packadd cfilter ]]
require('tms.diagnostic').setup()
-require('tms.lsp').setup()
require('tms.ws').setup()
diff --git a/lua/tms/diagnostic.lua b/lua/tms/diagnostic.lua
@@ -1,7 +1,6 @@
local M = {}
M.setup = function()
- -- Diagnositcs
vim.diagnostic.config({virtual_text = false, underline = false, float = {border = 'single'}, severity_sort = true})
vim.keymap.nnoremap {'gs', function() vim.diagnostic.open_float(0, {scope = 'line'}) end, silent = true}
diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua
@@ -29,15 +29,33 @@ local keybind = function(bufnr)
vim.keymap.nnoremap {'gwl', function() dump(vim.lsp.buf.list_workspace_folders()) end, silent = true, buffer = bufnr}
end
+local attach_callbacks = {}
+
local custom_attach = function(client, bufnr)
local lsp = vim.lsp
lsp.handlers['textDocument/hover'] = lsp.with(lsp.handlers.hover, {border = 'single'})
lsp.handlers['textDocument/signatureHelp'] = lsp.with(lsp.handlers.signature_help, {border = 'single'})
- require('aerial').on_attach(client, bufnr)
+ for _, cb in ipairs(attach_callbacks) do cb(client, bufnr) end
keybind(bufnr)
end
-local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
+local capabilities = function()
+ local ok, cnl = pcall(require, 'cmp_nvim_lsp')
+ if ok then
+ return cnl.update_capabilities(vim.lsp.protocol.make_client_capabilities())
+ else
+ return vim.lsp.protocol.make_client_capabilities()
+ end
+end
+
+local add_server = function(name)
+ local lspc = require('lspconfig')
+ local opts = {}
+ opts.on_attach = custom_attach
+ opts.capabilities = capabilities()
+ opts = servers.setup(name, opts)
+ lspc[name].setup(opts)
+end
M.setup = function()
-- LSP Installer
@@ -51,7 +69,7 @@ M.setup = function()
local opts = {}
opts = servers.setup(server.name, opts)
opts.on_attach = custom_attach
- opts.capabilities = capabilities
+ opts.capabilities = capabilities()
if server.name == 'sumneko_lua' then
opts = vim.tbl_deep_extend('force', server:get_default_options(), opts)
@@ -61,29 +79,14 @@ M.setup = function()
end)
-- Manual install
- local lspc = require('lspconfig')
local manual_servers = {
- -- 'null-ls',
'gdscript',
- 'dartls',
- -- 'sumneko_lua'
+ -- 'dartls'
}
- for _, name in ipairs(manual_servers) do
- local opts = {}
- opts.on_attach = custom_attach
- opts.capabilities = capabilities
- opts = servers.setup(name, opts)
- lspc[name].setup(opts)
- end
+ for _, name in ipairs(manual_servers) do add_server(name) end
end
-M.add = function(name)
- local lspc = require('lspconfig')
- local opts = {}
- opts.on_attach = custom_attach
- opts.capabilities = capabilities
- opts = servers.setup(name, opts)
- lspc[name].setup(opts)
-end
+M.add = function(name) add_server(name) end
+M.add_attach = function(cb) table.insert(attach_callbacks, cb) end
return M
diff --git a/lua/tms/p/aerial.lua b/lua/tms/p/aerial.lua
@@ -13,6 +13,7 @@ M.setup = function()
end)
require('telescope').load_extension('aerial')
+ require('tms.lsp').add_attach(function(client, bufnr) aerial.on_attach(client, bufnr) end)
end
return M
diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua
@@ -325,7 +325,7 @@ return packer.startup({
}
-- lsp
- use 'neovim/nvim-lspconfig'
+ use{ 'neovim/nvim-lspconfig' ,config=function() require('tms.lsp').setup() end}
use 'ii14/lsp-command'
use 'williamboman/nvim-lsp-installer'
use {