mirror of
https://git.aramjonghu.dev/AramJonghu/nvim.git
synced 2026-09-02 07:53:30 +02:00
stylua added rule
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
require("bufferline").setup {
|
||||
options = {
|
||||
diagnostics = "coc",
|
||||
diagnostics_indicator = function(count, level, diagnostics_dict, context)
|
||||
diagnostics_indicator = function(
|
||||
count,
|
||||
level,
|
||||
diagnostics_dict,
|
||||
context
|
||||
)
|
||||
local s = " "
|
||||
for e, n in pairs(diagnostics_dict) do
|
||||
local sym = e == "error" and " " or (e == "warning" and " " or " ")
|
||||
local sym = e == "error" and " "
|
||||
or (e == "warning" and " " or " ")
|
||||
s = s .. n .. sym
|
||||
end
|
||||
return s
|
||||
@@ -16,9 +22,7 @@ require("bufferline").setup {
|
||||
},
|
||||
vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, {
|
||||
callback = function()
|
||||
vim.schedule(function()
|
||||
pcall(nvim_bufferline)
|
||||
end)
|
||||
vim.schedule(function() pcall(nvim_bufferline) end)
|
||||
end,
|
||||
}),
|
||||
},
|
||||
|
||||
+7
-5
@@ -3,8 +3,12 @@ local cmp_lsp = require "cmp_nvim_lsp"
|
||||
|
||||
local M = {}
|
||||
|
||||
M.capabilities =
|
||||
vim.tbl_deep_extend("force", {}, vim.lsp.protocol.make_client_capabilities(), cmp_lsp.default_capabilities())
|
||||
M.capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
cmp_lsp.default_capabilities()
|
||||
)
|
||||
|
||||
local cmp_kinds = {
|
||||
Text = " ",
|
||||
@@ -47,9 +51,7 @@ cmp.setup {
|
||||
},
|
||||
completion = { completeopt = "menu,menuone" },
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
expand = function(args) require("luasnip").lsp_expand(args.body) end,
|
||||
},
|
||||
mapping = { -- change later zach is ????
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
|
||||
+9
-2
@@ -7,7 +7,10 @@ dap.adapters.python = function(cb, config)
|
||||
local host = (config.connect or config).host or "127.0.0.1"
|
||||
cb {
|
||||
type = "server",
|
||||
port = assert(port, "`connect.port` is required for a python `attach` configuration"),
|
||||
port = assert(
|
||||
port,
|
||||
"`connect.port` is required for a python `attach` configuration"
|
||||
),
|
||||
host = host,
|
||||
options = { source_filetype = "python" },
|
||||
}
|
||||
@@ -59,7 +62,11 @@ dap.configurations.cpp = {
|
||||
type = "lldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
return vim.fn.input(
|
||||
"Path to executable: ",
|
||||
vim.fn.getcwd() .. "/",
|
||||
"file"
|
||||
)
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
|
||||
+5
-15
@@ -6,22 +6,14 @@ local function on_attach(bufnr)
|
||||
end
|
||||
|
||||
map("n", "]g", function()
|
||||
if vim.wo.diff then
|
||||
return "]g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.next_hunk()
|
||||
end)
|
||||
if vim.wo.diff then return "]g" end
|
||||
vim.schedule(function() gs.next_hunk() end)
|
||||
return "<Ignore>"
|
||||
end, "Next hunk")
|
||||
|
||||
map("n", "[g", function()
|
||||
if vim.wo.diff then
|
||||
return "[g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.prev_hunk()
|
||||
end)
|
||||
if vim.wo.diff then return "[g" end
|
||||
vim.schedule(function() gs.prev_hunk() end)
|
||||
return "<Ignore>"
|
||||
end, "Prev hunk")
|
||||
|
||||
@@ -30,9 +22,7 @@ local function on_attach(bufnr)
|
||||
map("n", "<leader>hp", gs.preview_hunk, "Preview hunk")
|
||||
map("n", "<leader>hb", gs.blame_line, "Blame line")
|
||||
map("n", "<leader>hd", gs.diffthis, "Diff this")
|
||||
map("n", "<leader>hD", function()
|
||||
gs.diffthis "~"
|
||||
end, "Diff against ~")
|
||||
map("n", "<leader>hD", function() gs.diffthis "~" end, "Diff against ~")
|
||||
map("n", "<leader>htb", gs.toggle_current_line_blame, "Toggle line blame")
|
||||
map("n", "<leader>htd", gs.toggle_deleted, "Toggle deleted")
|
||||
end
|
||||
|
||||
@@ -21,6 +21,12 @@ hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
|
||||
end)
|
||||
|
||||
vim.g.rainbow_delimiters = { highlight = highlight }
|
||||
require("ibl").setup { indent = { char = "▏" }, scope = { highlight = highlight } }
|
||||
require("ibl").setup {
|
||||
indent = { char = "▏" },
|
||||
scope = { highlight = highlight },
|
||||
}
|
||||
|
||||
hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
|
||||
hooks.register(
|
||||
hooks.type.SCOPE_HIGHLIGHT,
|
||||
hooks.builtin.scope_highlight_from_extmark
|
||||
)
|
||||
|
||||
+15
-16
@@ -1,7 +1,9 @@
|
||||
local fn = vim.fn
|
||||
|
||||
local function get_coc_lsp_client()
|
||||
local clients = vim.g.coc_service_initialized and vim.fn["CocAction"] "services" or {}
|
||||
local clients = vim.g.coc_service_initialized
|
||||
and vim.fn["CocAction"] "services"
|
||||
or {}
|
||||
for _, client in pairs(clients) do
|
||||
if client["state"] == "running" then
|
||||
local client_name = client["id"]
|
||||
@@ -14,9 +16,7 @@ local function get_coc_lsp_client()
|
||||
end
|
||||
|
||||
local function spell()
|
||||
if vim.o.spell then
|
||||
return string.format "[SPELL]"
|
||||
end
|
||||
if vim.o.spell then return string.format "[SPELL]" end
|
||||
|
||||
return ""
|
||||
end
|
||||
@@ -24,11 +24,10 @@ end
|
||||
--- show indicator for Chinese IME
|
||||
local function ime_state()
|
||||
if vim.g.is_mac then
|
||||
local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
|
||||
local layout =
|
||||
fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
|
||||
local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
|
||||
if res ~= -1 then
|
||||
return "[CN]"
|
||||
end
|
||||
if res ~= -1 then return "[CN]" end
|
||||
end
|
||||
|
||||
return ""
|
||||
@@ -36,24 +35,21 @@ end
|
||||
|
||||
local diff = function()
|
||||
local git_status = vim.b.gitsigns_status_dict
|
||||
if git_status == nil then
|
||||
return
|
||||
end
|
||||
if git_status == nil then return end
|
||||
|
||||
local modify_num = git_status.changed
|
||||
local remove_num = git_status.removed
|
||||
local add_num = git_status.added
|
||||
|
||||
local info = { added = add_num, modified = modify_num, removed = remove_num }
|
||||
local info =
|
||||
{ added = add_num, modified = modify_num, removed = remove_num }
|
||||
-- vim.print(info)
|
||||
return info
|
||||
end
|
||||
|
||||
local virtual_env = function()
|
||||
-- only show virtual env for Python
|
||||
if vim.bo.filetype ~= "python" then
|
||||
return ""
|
||||
end
|
||||
if vim.bo.filetype ~= "python" then return "" end
|
||||
|
||||
local conda_env = os.getenv "CONDA_DEFAULT_ENV"
|
||||
local venv_path = os.getenv "VIRTUAL_ENV"
|
||||
@@ -116,7 +112,10 @@ require("lualine").setup {
|
||||
},
|
||||
lualine_y = {
|
||||
{ "encoding", fmt = string.upper },
|
||||
{ "fileformat", symbols = { unix = "", dos = "", mac = "" } },
|
||||
{
|
||||
"fileformat",
|
||||
symbols = { unix = "", dos = "", mac = "" },
|
||||
},
|
||||
"filetype",
|
||||
},
|
||||
lualine_z = { "progress" },
|
||||
|
||||
+55
-33
@@ -26,9 +26,7 @@ require("notify").setup {
|
||||
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] then client_notifs[client_id] = {} end
|
||||
|
||||
if not client_notifs[client_id][token] then
|
||||
client_notifs[client_id][token] = {}
|
||||
@@ -37,7 +35,8 @@ local function get_notif_data(client_id, token)
|
||||
return client_notifs[client_id][token]
|
||||
end
|
||||
|
||||
local spinner_frames = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }
|
||||
local spinner_frames =
|
||||
{ "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }
|
||||
|
||||
local function update_spinner(client_id, token)
|
||||
local notif_data = get_notif_data(client_id, token)
|
||||
@@ -52,9 +51,7 @@ local function update_spinner(client_id, token)
|
||||
replace = notif_data.notification,
|
||||
})
|
||||
|
||||
vim.defer_fn(function()
|
||||
update_spinner(client_id, token)
|
||||
end, 100)
|
||||
vim.defer_fn(function() update_spinner(client_id, token) end, 100)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,9 +71,7 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
|
||||
local val = result.value
|
||||
|
||||
if not val.kind then
|
||||
return
|
||||
end
|
||||
if not val.kind then return end
|
||||
|
||||
local notif_data = get_notif_data(client_id, result.token)
|
||||
|
||||
@@ -84,7 +79,10 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
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),
|
||||
title = format_title(
|
||||
val.title,
|
||||
vim.lsp.get_client_by_id(client_id).name
|
||||
),
|
||||
icon = spinner_frames[1],
|
||||
timeout = false,
|
||||
hide_from_history = false,
|
||||
@@ -93,16 +91,21 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
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,
|
||||
})
|
||||
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.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
|
||||
@@ -111,14 +114,22 @@ end
|
||||
-- table from lsp severity to vim severity.
|
||||
local severity = { "error", "warn", "info" }
|
||||
|
||||
vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
|
||||
vim.lsp.handlers["window/showMessage"] = function(
|
||||
err,
|
||||
method,
|
||||
params,
|
||||
client_id
|
||||
)
|
||||
vim.notify(method.message, severity[params.type])
|
||||
end
|
||||
|
||||
-- DAP integration
|
||||
-- Make sure to also have the snippet with the common helper functions in your config!
|
||||
|
||||
dap.listeners.before["event_progressStart"]["progress-notifications"] = function(session, body)
|
||||
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)
|
||||
@@ -132,20 +143,31 @@ dap.listeners.before["event_progressStart"]["progress-notifications"] = function
|
||||
notif_data.notification.spinner = 1, update_spinner("dap", body.progressId)
|
||||
end
|
||||
|
||||
dap.listeners.before["event_progressUpdate"]["progress-notifications"] = function(session, body)
|
||||
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,
|
||||
})
|
||||
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)
|
||||
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.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
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
if not vim.F then
|
||||
vim.F = {}
|
||||
end
|
||||
if not vim.F then vim.F = {} end
|
||||
|
||||
if not vim.F.if_nil and not vim.nonnil then
|
||||
vim.F.if_nil = function(value, default)
|
||||
if value == nil then
|
||||
return default
|
||||
end
|
||||
if value == nil then return default end
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user