mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-08 10:48:01 -08:00
Compare commits
3 Commits
c3a73c4a00
...
8f49547f85
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f49547f85 | ||
|
|
a53991c53d | ||
|
|
180160fee1 |
@@ -13,6 +13,10 @@ vim.g.mapleader = " "
|
|||||||
vim.g.maplocalleader = ","
|
vim.g.maplocalleader = ","
|
||||||
|
|
||||||
-- Create a custom command with the given trigger, command, and description
|
-- Create a custom command with the given trigger, command, and description
|
||||||
|
--- @param trigger string The command trigger
|
||||||
|
--- @param command string The command to execute
|
||||||
|
--- @param description string Description of the command
|
||||||
|
--- @return nil
|
||||||
function create_custom_command(trigger, command, description)
|
function create_custom_command(trigger, command, description)
|
||||||
vim.api.nvim_create_user_command(trigger, command, { desc = description })
|
vim.api.nvim_create_user_command(trigger, command, { desc = description })
|
||||||
end
|
end
|
||||||
@@ -21,6 +25,10 @@ create_custom_command("Config", "edit ~/.config/nvim", "Edit nvim configuration"
|
|||||||
create_custom_command("Keymaps", "edit ~/.config/nvim/lua/core/keymaps.lua", "Edit Hyprland keybindings")
|
create_custom_command("Keymaps", "edit ~/.config/nvim/lua/core/keymaps.lua", "Edit Hyprland keybindings")
|
||||||
create_custom_command("Hypr", "edit ~/.config/hypr/hyprland.conf", "Edit Hyprland configuration")
|
create_custom_command("Hypr", "edit ~/.config/hypr/hyprland.conf", "Edit Hyprland configuration")
|
||||||
|
|
||||||
|
vim.keymap.set("", "<Leader>tl", function()
|
||||||
|
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||||
|
end, { desc = "Toggle diagnostics virtual text" })
|
||||||
|
|
||||||
-- {{{ Basic Mappings
|
-- {{{ Basic Mappings
|
||||||
local basic_mappings = {
|
local basic_mappings = {
|
||||||
{ key = "<C-u>", cmd = "<C-u>zz", desc = "Scroll up and center", mode = "n" },
|
{ key = "<C-u>", cmd = "<C-u>zz", desc = "Scroll up and center", mode = "n" },
|
||||||
|
|||||||
@@ -73,13 +73,14 @@ local border = {
|
|||||||
o.winborder = "rounded"
|
o.winborder = "rounded"
|
||||||
|
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = true,
|
virtual_text = {
|
||||||
|
format = function(diagnostic)
|
||||||
|
-- You can customize the display text per diagnostic
|
||||||
|
return string.format("[%s]: %s", diagnostic.code, diagnostic.message)
|
||||||
|
end,
|
||||||
|
},
|
||||||
signs = true,
|
signs = true,
|
||||||
underline = true,
|
underline = true,
|
||||||
float = { border = "rounded", source = true },
|
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
|
update_in_insert = false,
|
||||||
})
|
})
|
||||||
vim.keymap.set("", "<Leader>tl", function()
|
|
||||||
local current = vim.diagnostic.config().virtual_text
|
|
||||||
vim.diagnostic.config({ virtual_text = not current })
|
|
||||||
end, { desc = "Toggle diagnostics virtual text" })
|
|
||||||
|
|||||||
17
.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua
Normal file
17
.config/nvim/lua/plugins/better-diagnostic-virtual-text.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
return {
|
||||||
|
"sontungexpt/better-diagnostic-virtual-text",
|
||||||
|
event = "LspAttach",
|
||||||
|
opts = {
|
||||||
|
ui = {
|
||||||
|
wrap_line_after = 150, -- wrap the line after this length to avoid the virtual text is too long
|
||||||
|
left_kept_space = 3, --- the number of spaces kept on the left side of the virtual text, make sure it enough to custom for each line
|
||||||
|
right_kept_space = 3, --- the number of spaces kept on the right side of the virtual text, make sure it enough to custom for each line
|
||||||
|
arrow = " ",
|
||||||
|
up_arrow = " ",
|
||||||
|
down_arrow = " ",
|
||||||
|
above = false, -- the virtual text will be displayed above the line
|
||||||
|
},
|
||||||
|
priority = 2003, -- the priority of virtual text
|
||||||
|
inline = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
return {
|
|
||||||
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
|
|
||||||
config = function()
|
|
||||||
-- lsp_lines
|
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
|
||||||
-- --
|
|
||||||
vim.keymap.set("", "<Leader>tl", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" })
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,22 @@
|
|||||||
|
local function set_python_path(path)
|
||||||
|
local clients = vim.lsp.get_clients({
|
||||||
|
bufnr = vim.api.nvim_get_current_buf(),
|
||||||
|
name = "basedpyright",
|
||||||
|
})
|
||||||
|
for _, client in ipairs(clients) do
|
||||||
|
if client.settings then
|
||||||
|
client.settings.python = vim.tbl_deep_extend("force", client.settings.python or {}, { pythonPath = path })
|
||||||
|
else
|
||||||
|
client.config.settings =
|
||||||
|
vim.tbl_deep_extend("force", client.config.settings, { python = { pythonPath = path } })
|
||||||
|
end
|
||||||
|
client:notify("workspace/didChangeConfiguration", { settings = nil })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
config = function()
|
config = function()
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
vim.notify = require("notify")
|
vim.notify = require("notify")
|
||||||
local servers = {
|
local servers = {
|
||||||
"bashls",
|
"bashls",
|
||||||
@@ -82,11 +97,32 @@ return {
|
|||||||
autoSearchPaths = true,
|
autoSearchPaths = true,
|
||||||
diagnosticMode = "openFilesOnly",
|
diagnosticMode = "openFilesOnly",
|
||||||
useLibraryCodeForTypes = true,
|
useLibraryCodeForTypes = true,
|
||||||
|
autoFormatStrings = true,
|
||||||
},
|
},
|
||||||
diagnosticMode = "openFilesOnly",
|
diagnosticMode = "openFilesOnly",
|
||||||
inlayHints = {
|
inlayHints = {
|
||||||
callArgumentNames = true,
|
callArgumentNames = true,
|
||||||
},
|
},
|
||||||
|
allowedUntypedLibraries = true,
|
||||||
|
reportMissingTypeStubs = false,
|
||||||
|
reportImportCycles = true,
|
||||||
|
reportUnusedImport = true,
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LspPyrightOrganizeImports", function()
|
||||||
|
client:exec_cmd({
|
||||||
|
command = "basedpyright.organizeimports",
|
||||||
|
arguments = { vim.uri_from_bufnr(bufnr) },
|
||||||
|
})
|
||||||
|
end, {
|
||||||
|
desc = "Organize Imports",
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LspPyrightSetPythonPath", set_python_path, {
|
||||||
|
desc = "Reconfigure basedpyright with the provided python path",
|
||||||
|
nargs = 1,
|
||||||
|
complete = "file",
|
||||||
|
})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
vim.lsp.enable(lsp)
|
vim.lsp.enable(lsp)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,21 +6,52 @@ return {
|
|||||||
-- syncronous formatting
|
-- syncronous formatting
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
|
|
||||||
-- null_ls.setup({
|
local sources = {
|
||||||
-- on_attach = function(client)
|
null_ls.builtins.completion.luasnip,
|
||||||
-- if client.supports_method "textDocument/formatting" then
|
-- null_ls.builtins.diagnostics.mypy,
|
||||||
-- vim.cmd([[
|
null_ls.builtins.diagnostics.pydoclint,
|
||||||
-- augroup LspFormatting
|
null_ls.builtins.diagnostics.markdownlint,
|
||||||
-- autocmd! * <buffer>
|
null_ls.builtins.formatting.black,
|
||||||
-- autocmd BufWritePre <buffer> lua vim.lsp.buf.format()
|
null_ls.builtins.formatting.isort,
|
||||||
-- augroup END
|
null_ls.builtins.formatting.stylua,
|
||||||
-- ]])
|
null_ls.builtins.formatting.markdownlint,
|
||||||
-- end
|
null_ls.builtins.formatting.prettier, -- handled by lsp server
|
||||||
-- end,
|
null_ls.builtins.formatting.shfmt.with({
|
||||||
-- })
|
filetypes = { "sh", "bash" },
|
||||||
-- you can reuse a shared lspconfig on_attach callback here
|
extra_args = { "-i", "0", "-ci", "-sr" },
|
||||||
|
}),
|
||||||
|
null_ls.builtins.formatting.gofmt,
|
||||||
|
null_ls.builtins.formatting.goimports,
|
||||||
|
null_ls.builtins.formatting.goimports_reviser,
|
||||||
|
null_ls.builtins.hover.printenv,
|
||||||
|
}
|
||||||
|
|
||||||
require("null-ls").setup({
|
require("null-ls").setup({
|
||||||
|
border = "rounded",
|
||||||
|
cmd = { "nvim" },
|
||||||
|
debounce = 250,
|
||||||
|
debug = false,
|
||||||
|
default_timeout = 5000,
|
||||||
|
diagnostic_config = {
|
||||||
|
virtual_text = false,
|
||||||
|
signs = true,
|
||||||
|
underline = true,
|
||||||
|
float = { border = "rounded", source = true },
|
||||||
|
severity_sort = true,
|
||||||
|
},
|
||||||
|
-- diagnostics_format = "#{m}",
|
||||||
|
diagnostics_format = "[#{c}] #{m} (#{s})",
|
||||||
|
fallback_severity = vim.diagnostic.severity.ERROR,
|
||||||
|
log_level = "warn",
|
||||||
|
notify_format = "[null-ls] %s",
|
||||||
|
on_init = nil,
|
||||||
|
on_exit = nil,
|
||||||
|
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git"),
|
||||||
|
root_dir_async = nil,
|
||||||
|
should_attach = nil,
|
||||||
|
sources = sources,
|
||||||
|
temp_dir = nil,
|
||||||
|
update_in_insert = false,
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
if client.supports_method("textDocument/formatting") then
|
if client.supports_method("textDocument/formatting") then
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
@@ -28,9 +59,6 @@ return {
|
|||||||
group = augroup,
|
group = augroup,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
|
||||||
-- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead
|
|
||||||
-- vim.lsp.buf.formatting_sync()
|
|
||||||
vim.lsp.buf.format({
|
vim.lsp.buf.format({
|
||||||
async = false,
|
async = false,
|
||||||
bufnr = bufnr,
|
bufnr = bufnr,
|
||||||
@@ -42,32 +70,6 @@ return {
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
sources = {
|
|
||||||
null_ls.builtins.completion.luasnip,
|
|
||||||
null_ls.builtins.formatting.black,
|
|
||||||
null_ls.builtins.formatting.isort,
|
|
||||||
null_ls.builtins.diagnostics.mypy,
|
|
||||||
null_ls.builtins.diagnostics.markdownlint,
|
|
||||||
null_ls.builtins.diagnostics.pylint,
|
|
||||||
-- null_ls.builtins.diagnostics.pydocstyle.with({
|
|
||||||
-- extra_arags = { "--config=$ROOT/setup.cfg" },
|
|
||||||
-- }),
|
|
||||||
-- null_ls.builtins.diagnostics.pydoclint,
|
|
||||||
null_ls.builtins.formatting.stylua,
|
|
||||||
-- null_ls.builtins.formatting.stylua.with({
|
|
||||||
-- extra_args = { '--config-path', vim.fn.expand('~/.config/stylua.toml') },
|
|
||||||
-- }),
|
|
||||||
null_ls.builtins.formatting.markdownlint,
|
|
||||||
null_ls.builtins.formatting.prettier, -- handled by lsp server
|
|
||||||
null_ls.builtins.formatting.shfmt.with({
|
|
||||||
filetypes = { "sh", "bash" },
|
|
||||||
extra_args = { "-i", "0", "-ci", "-sr" },
|
|
||||||
}),
|
|
||||||
null_ls.builtins.formatting.gofmt,
|
|
||||||
null_ls.builtins.formatting.goimports,
|
|
||||||
null_ls.builtins.formatting.goimports_reviser,
|
|
||||||
-- null_ls.builtins.diagnostics.actionlint,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ return {
|
|||||||
behavior = cmp.ConfirmBehavior.Replace,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
select = false,
|
select = false,
|
||||||
}),
|
}),
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = vim.schedule_wrap(function(fallback)
|
||||||
if cmp.visible() and has_words_before() then
|
if cmp.visible() and has_words_before() then
|
||||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||||
elseif luasnip.locally_jumpable(1) then
|
elseif luasnip.locally_jumpable(1) then
|
||||||
@@ -99,7 +99,16 @@ return {
|
|||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end),
|
||||||
|
-- ["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
-- if cmp.visible() and has_words_before() then
|
||||||
|
-- cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||||
|
-- elseif luasnip.locally_jumpable(1) then
|
||||||
|
-- luasnip.jump(1)
|
||||||
|
-- else
|
||||||
|
-- fallback()
|
||||||
|
-- end
|
||||||
|
-- end, { "i", "s" }),
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
@@ -244,18 +253,6 @@ return {
|
|||||||
require("copilot_cmp.comparators").sort_text,
|
require("copilot_cmp.comparators").sort_text,
|
||||||
require("copilot_cmp.comparators").length,
|
require("copilot_cmp.comparators").length,
|
||||||
require("copilot_cmp.comparators").order,
|
require("copilot_cmp.comparators").order,
|
||||||
|
|
||||||
-- Below is the default comparitor list and order for nvim-cmp
|
|
||||||
cmp.config.compare.offset,
|
|
||||||
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
|
|
||||||
cmp.config.compare.exact,
|
|
||||||
cmp.config.compare.score,
|
|
||||||
cmp.config.compare.recently_used,
|
|
||||||
cmp.config.compare.locality,
|
|
||||||
cmp.config.compare.kind,
|
|
||||||
cmp.config.compare.sort_text,
|
|
||||||
cmp.config.compare.length,
|
|
||||||
cmp.config.compare.order,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ return {
|
|||||||
vim = { "vint" },
|
vim = { "vint" },
|
||||||
go = { "golangcilint" },
|
go = { "golangcilint" },
|
||||||
}
|
}
|
||||||
local shellcheck = require("lint").linters.shellcheck
|
lint.linters.shellcheck.args = {
|
||||||
shellcheck.args = {
|
|
||||||
"-s",
|
"-s",
|
||||||
"bash",
|
"bash",
|
||||||
"-o",
|
"-o",
|
||||||
@@ -21,10 +20,8 @@ return {
|
|||||||
"-e",
|
"-e",
|
||||||
"2250",
|
"2250",
|
||||||
}
|
}
|
||||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||||
group = lint_augroup,
|
|
||||||
callback = function()
|
callback = function()
|
||||||
lint.try_lint()
|
lint.try_lint()
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -2,6 +2,13 @@ local M = {}
|
|||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
--- Set keybindings from a table of mappings.
|
||||||
|
--- @param bindings table A list of keybinding mappings.
|
||||||
|
--- Each mapping should be a table with the following keys:
|
||||||
|
--- - mode: string, the mode in which the keybinding applies (e.g., 'n', 'i', 'v').
|
||||||
|
--- - key: string, the key to bind.
|
||||||
|
--- - cmd: string, the command to execute when the key is pressed.
|
||||||
|
--- - opts: table, optional, additional options for the keybinding (default:
|
||||||
function M.set_keybindings(bindings)
|
function M.set_keybindings(bindings)
|
||||||
for _, binding in ipairs(bindings) do
|
for _, binding in ipairs(bindings) do
|
||||||
map(binding.mode, binding.key, binding.cmd, binding.opts or opts)
|
map(binding.mode, binding.key, binding.cmd, binding.opts or opts)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ local whichkey = require("which-key")
|
|||||||
vim.notify = require("notify")
|
vim.notify = require("notify")
|
||||||
|
|
||||||
---Helper function to add mappings to which-key
|
---Helper function to add mappings to which-key
|
||||||
---@parm mappings table : List of mappings to add to which-key
|
---@param mappings table List of mappings to add
|
||||||
---@parm group table : Group to add mappings to (optional)
|
---@param group table Group to add mappings to (optional)
|
||||||
---@return nil
|
---@return nil
|
||||||
---@usage addToWhichKey(mappings, group)
|
---@usage addToWhichKey(mappings, group)
|
||||||
---@example addToWhichKey({{key = "n", cmd = "next", mode = "n", desc = "Next Line", group = "Navigation"}, {key = "t", group = "example"})
|
---@example addToWhichKey({{key = "n", cmd = "next", mode = "n", desc = "Next Line", group = "Navigation"}, {key = "t", group = "example"})
|
||||||
|
|||||||
Reference in New Issue
Block a user