commit c5c4b7c3c1bc6df4957bffec5742ec7ac350aa53
parent b2f1f6d09c250e69db30cfe26cdf726b3be6758b
Author: Tomas Nemec <nemi@skaut.cz>
Date: Wed, 11 May 2022 09:34:54 +0200
update
Diffstat:
7 files changed, 96 insertions(+), 11 deletions(-)
diff --git a/after/plugin/bqf.lua b/after/plugin/bqf.lua
@@ -1,3 +1,3 @@
if not pcall(require, 'bqf') then return end
-require('bqf').setup { auto_enable = true, auto_resize_height = true, preview = { auto_preview = false } }
+require('bqf').setup { auto_enable = true, auto_resize_height = false, preview = { auto_preview = true } }
diff --git a/after/plugin/notify.lua b/after/plugin/notify.lua
@@ -1,10 +1,6 @@
if not pcall(require, 'notify') then return end
local notify = require('notify')
-notify.setup({
- on_open = function(win) vim.api.nvim_win_set_config(win, { focusable = false }) end,
- stages = 'slide',
- render = 'minimal',
-})
+notify.setup({ on_open = function(win) vim.api.nvim_win_set_config(win, { focusable = false }) end, stages = 'slide' })
vim.notify = notify
vim.keymap.set('n', '<leader>N', require('notify').dismiss, { noremap = true, desc = 'Dismiss notification' })
diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua
@@ -78,3 +78,7 @@ require'nvim-treesitter.configs'.setup {
vim.api.nvim_create_user_command('TSHRefresh', 'write|TSBufEnable highlight', {})
vim.keymap.set('n', '<leader>su', '<cmd>TSHRefresh<cr>')
+
+require('tms.colors').update(function(t)
+ t.Group.new('TreesitterContext', t.colors.none, t.dimm(t.groups.Normal.bg, 0.03))
+end)
diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua
@@ -1,4 +1,6 @@
+local lsp = vim.lsp
local servers = require('tms.lsp.servers')
+-- local progress = require('tms.lsp.progress')
local format_setup = function(client, bufnr)
vim.keymap.set('n', 'Q', function()
@@ -10,10 +12,6 @@ local format_setup = function(client, bufnr)
end
local on_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' })
vim.api.nvim_buf_set_option(bufnr, 'tagfunc', 'v:lua.vim.lsp.tagfunc')
vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
@@ -54,6 +52,13 @@ local make_opts = function(name)
end
local setup = function()
+ lsp.handlers['textDocument/hover'] = lsp.with(lsp.handlers.hover, { border = 'single' })
+ lsp.handlers['textDocument/signatureHelp'] = lsp.with(lsp.handlers.signature_help, { border = 'single' })
+ -- lsp.handlers['$/progress'] = progress.handler
+ -- local severity = { 'error', 'warn', 'info' }
+ -- lsp.handlers['window/showMessage'] =
+ -- function(_, method, params, _) vim.notify(method.message, severity[params.type]) end
+
-- LSP Installer
local has_lspi, lsp_installer = pcall(require, 'nvim-lsp-installer')
if has_lspi then lsp_installer.setup({}) end
diff --git a/lua/tms/lsp/progress.lua b/lua/tms/lsp/progress.lua
@@ -0,0 +1,69 @@
+local M = {}
+
+local client_notifs = {}
+
+local function get_notif_data(client_id, token)
+ if not client_notifs[client_id] then client_notifs[client_id] = {} end
+
+ if not client_notifs[client_id][token] then client_notifs[client_id][token] = {} end
+
+ return client_notifs[client_id][token]
+end
+
+local spinner_frames = { '⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷' }
+
+local function update_spinner(client_id, token)
+ local notif_data = get_notif_data(client_id, token)
+
+ if notif_data.spinner then
+ local new_spinner = (notif_data.spinner + 1) % #spinner_frames
+ notif_data.spinner = new_spinner
+
+ notif_data.notification = vim.notify(nil, nil, {
+ hide_from_history = true,
+ icon = spinner_frames[new_spinner],
+ replace = notif_data.notification,
+ })
+
+ vim.defer_fn(function() update_spinner(client_id, token) end, 100)
+ end
+end
+
+local function format_title(title, client_name) return client_name .. (#title > 0 and ': ' .. title or '') end
+
+local function format_message(message, percentage) return (percentage and percentage .. '%\t' or '') .. (message or '') end
+
+M.handler = function(_, result, ctx)
+ local client_id = ctx.client_id
+
+ local val = result.value
+
+ if not val.kind then return end
+ print(val.kind)
+
+ local notif_data = get_notif_data(client_id, result.token)
+
+ if val.kind == 'begin' then
+ local message = format_message(val.message, val.percentage)
+
+ notif_data.notification = vim.notify(message, 'info', {
+ title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
+ icon = spinner_frames[1],
+ timeout = false,
+ hide_from_history = false,
+ })
+
+ notif_data.spinner = 1
+ update_spinner(client_id, result.token)
+ elseif val.kind == 'report' and notif_data then
+ notif_data.notification = vim.notify(format_message(val.message, val.percentage), 'info',
+ { replace = notif_data.notification, hide_from_history = false })
+ elseif val.kind == 'end' and notif_data then
+ notif_data.notification = vim.notify(val.message and format_message(val.message) or 'Complete', 'info',
+ { icon = '', replace = notif_data.notification, timeout = 3000 })
+
+ notif_data.spinner = nil
+ end
+end
+
+return M
diff --git a/lua/tms/lsp/servers.lua b/lua/tms/lsp/servers.lua
@@ -52,7 +52,17 @@ S.sumneko_lua = function(opts)
opts.settings = {
Lua = { runtime = { version = 'LuaJIT' }, diagnostics = { globals = { 'vim' } }, telemetry = { enable = false } },
}
- -- opts = require('lua-dev').setup({ lspconfig = opts })
+ opts = require('lua-dev').setup({
+ library = {
+ vimruntime = true, -- runtime path
+ types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
+ plugins = false, -- installed opt or start plugins in packpath
+ -- you can also specify the list of plugins to make available as a workspace library
+ -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
+ },
+ runtime_path = true, -- enable this to get completion in require strings. Slow!
+ lspconfig = opts,
+ })
return opts
end
diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua
@@ -125,6 +125,7 @@ return packer.startup({
use 'nvim-treesitter/nvim-treesitter-refactor'
use 'nvim-treesitter/playground'
use 'JoosepAlviste/nvim-ts-context-commentstring'
+ use 'lewis6991/nvim-treesitter-context'
-- telescope
use {