nvim
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'QuitPre'}, {
|
||||
nested = false,
|
||||
callback = function(e)
|
||||
local tree = require('nvim-tree.api').tree
|
||||
|
||||
-- Nothing to do if tree is not opened
|
||||
if not tree.is_visible() then
|
||||
return
|
||||
end
|
||||
|
||||
-- How many focusable windows do we have? (excluding e.g. incline status window)
|
||||
local winCount = 0
|
||||
for _,winId in ipairs(vim.api.nvim_list_wins()) do
|
||||
if vim.api.nvim_win_get_config(winId).focusable then
|
||||
winCount = winCount + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- We want to quit and only one window besides tree is left
|
||||
if e.event == 'QuitPre' and winCount == 2 then
|
||||
vim.api.nvim_cmd({cmd = 'qall'}, {})
|
||||
end
|
||||
|
||||
-- :bd was probably issued an only tree window is left
|
||||
-- Behave as if tree was closed (see `:h :bd`)
|
||||
if e.event == 'BufEnter' and winCount == 1 then
|
||||
-- Required to avoid "Vim:E444: Cannot close last window"
|
||||
vim.defer_fn(function()
|
||||
-- close nvim-tree: will go to the last buffer used before closing
|
||||
tree.toggle({find_file = true, focus = true})
|
||||
-- re-open nivm-tree
|
||||
tree.toggle({find_file = true, focus = false})
|
||||
end, 10)
|
||||
end
|
||||
end
|
||||
})
|
||||
@@ -0,0 +1,62 @@
|
||||
require("focus").setup({
|
||||
enable = true,
|
||||
commands = true,
|
||||
autoresize = {
|
||||
enable = true,
|
||||
width = 0,
|
||||
height = 0,
|
||||
minwidth = 0,
|
||||
minheight = 0,
|
||||
height_quickfix = 10,
|
||||
},
|
||||
split = {
|
||||
bufnew = false,
|
||||
tmux = false,
|
||||
},
|
||||
ui = {
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
hybridnumber = false,
|
||||
absolutenumber_unfocussed = false,
|
||||
|
||||
cursorline = true,
|
||||
cursorcolumn = false,
|
||||
colorcolumn = {
|
||||
enable = false,
|
||||
list = '+1',
|
||||
},
|
||||
signcolumn = false,
|
||||
winhighlight = false,
|
||||
}
|
||||
})
|
||||
|
||||
local ignore_filetypes = {"NvimTree"}
|
||||
local ignore_buftypes = {"prompt", "popup"}
|
||||
|
||||
local augroup =
|
||||
vim.api.nvim_create_augroup("FocusDisable", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("WinEnter", {
|
||||
group = augroup,
|
||||
callback = function(_)
|
||||
if vim.tbl_contains(ignore_buftypes, vim.bo.buftype)
|
||||
then
|
||||
vim.w.focus_disable = true
|
||||
else
|
||||
vim.w.focus_disable = false
|
||||
end
|
||||
end,
|
||||
desc = "Disable focus autoresize for BufType",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup,
|
||||
callback = function(_)
|
||||
if vim.tbl_contains(ignore_filetypes, vim.bo.filetype) then
|
||||
vim.b.focus_disable = true
|
||||
else
|
||||
vim.b.focus_disable = false
|
||||
end
|
||||
end,
|
||||
desc = "Disable focus autoresize for FileType",
|
||||
})
|
||||
@@ -125,7 +125,7 @@ local servers = {
|
||||
"texlab",
|
||||
"pyright",
|
||||
"ts_ls",
|
||||
"jdtls",
|
||||
-- "jdtls",
|
||||
"sourcekit",
|
||||
"zls",
|
||||
}
|
||||
@@ -134,3 +134,12 @@ for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup {
|
||||
}
|
||||
end
|
||||
|
||||
-- lspconfig.jdtls.setup {
|
||||
-- cmd = { "jdtls", "-Dfile.encoding=UTF-8" },
|
||||
-- }
|
||||
|
||||
-- lspconfig.java_language_server.setup {
|
||||
-- filetypes = { "java" },
|
||||
-- cmd = { "/usr/share/java/java-language-server/lang_server_linux.sh" },
|
||||
-- }
|
||||
|
||||
+82
-82
@@ -67,85 +67,85 @@ local function format_message(message, percentage)
|
||||
return (percentage and percentage .. "%\t" or "") .. (message or "")
|
||||
end
|
||||
|
||||
vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
local client_id = ctx.client_id
|
||||
|
||||
local val = result.value
|
||||
|
||||
if not val.kind then
|
||||
return
|
||||
end
|
||||
|
||||
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 = 6000,
|
||||
})
|
||||
|
||||
notif_data.spinner = nil
|
||||
end
|
||||
end
|
||||
|
||||
local severity = {
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"info", -- map both hint and info to info?
|
||||
}
|
||||
vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
|
||||
vim.notify(method.message, severity[params.type])
|
||||
end
|
||||
|
||||
dap.listeners.before['event_progressStart']['progress-notifications'] = function(session, body)
|
||||
local notif_data = get_notif_data("dap", body.progressId)
|
||||
|
||||
local message = format_message(body.message, body.percentage)
|
||||
notif_data.notification = vim.notify(message, "info", {
|
||||
title = format_title(body.title, session.config.type),
|
||||
icon = spinner_frames[1],
|
||||
timeout = false,
|
||||
hide_from_history = false,
|
||||
})
|
||||
|
||||
notif_data.notification.spinner = 1,
|
||||
update_spinner("dap", body.progressId)
|
||||
end
|
||||
|
||||
dap.listeners.before['event_progressUpdate']['progress-notifications'] = function(session, body)
|
||||
local notif_data = get_notif_data("dap", body.progressId)
|
||||
notif_data.notification = vim.notify(format_message(body.message, body.percentage), "info", {
|
||||
replace = notif_data.notification,
|
||||
hide_from_history = false,
|
||||
})
|
||||
end
|
||||
|
||||
dap.listeners.before['event_progressEnd']['progress-notifications'] = function(session, body)
|
||||
local notif_data = client_notifs["dap"][body.progressId]
|
||||
notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", {
|
||||
icon = "",
|
||||
replace = notif_data.notification,
|
||||
timeout = 6000
|
||||
})
|
||||
notif_data.spinner = nil
|
||||
end
|
||||
-- vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
-- local client_id = ctx.client_id
|
||||
--
|
||||
-- local val = result.value
|
||||
--
|
||||
-- if not val.kind then
|
||||
-- return
|
||||
-- end
|
||||
--
|
||||
-- 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 = 6000,
|
||||
-- })
|
||||
--
|
||||
-- notif_data.spinner = nil
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- local severity = {
|
||||
-- "error",
|
||||
-- "warn",
|
||||
-- "info",
|
||||
-- "info", -- map both hint and info to info?
|
||||
-- }
|
||||
-- vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
|
||||
-- vim.notify(method.message, severity[params.type])
|
||||
-- end
|
||||
--
|
||||
-- dap.listeners.before['event_progressStart']['progress-notifications'] = function(session, body)
|
||||
-- local notif_data = get_notif_data("dap", body.progressId)
|
||||
--
|
||||
-- local message = format_message(body.message, body.percentage)
|
||||
-- notif_data.notification = vim.notify(message, "info", {
|
||||
-- title = format_title(body.title, session.config.type),
|
||||
-- icon = spinner_frames[1],
|
||||
-- timeout = false,
|
||||
-- hide_from_history = false,
|
||||
-- })
|
||||
--
|
||||
-- notif_data.notification.spinner = 1,
|
||||
-- update_spinner("dap", body.progressId)
|
||||
-- end
|
||||
--
|
||||
-- dap.listeners.before['event_progressUpdate']['progress-notifications'] = function(session, body)
|
||||
-- local notif_data = get_notif_data("dap", body.progressId)
|
||||
-- notif_data.notification = vim.notify(format_message(body.message, body.percentage), "info", {
|
||||
-- replace = notif_data.notification,
|
||||
-- hide_from_history = false,
|
||||
-- })
|
||||
-- end
|
||||
--
|
||||
-- dap.listeners.before['event_progressEnd']['progress-notifications'] = function(session, body)
|
||||
-- local notif_data = client_notifs["dap"][body.progressId]
|
||||
-- notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", {
|
||||
-- icon = "",
|
||||
-- replace = notif_data.notification,
|
||||
-- timeout = 6000
|
||||
-- })
|
||||
-- notif_data.spinner = nil
|
||||
-- end
|
||||
|
||||
@@ -182,4 +182,13 @@ return {
|
||||
{
|
||||
"andweeb/presence.nvim",
|
||||
},
|
||||
{
|
||||
"nvim-focus/focus.nvim",
|
||||
config = function()
|
||||
require("config.focus")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-jdtls",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user