Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fetch/upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
misumisumi committed Feb 8, 2025
2 parents 150d144 + ddf7f5e commit c732ca3
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
- uses: actions/checkout@v4
- uses: lunarmodules/luacheck@v1
with:
args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _telescope_collections _toggle_lazygit _toggle_diagnostic _toggle_inlayhint _async_compile_and_debug --max-line-length 150 --no-config
args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _telescope_collections _toggle_lazygit _toggle_diagnostic _toggle_inlayhint --max-line-length 150 --no-config
26 changes: 13 additions & 13 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lua/keymap/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ function M.lsp(buf)
:with_silent()
:with_buffer(buf)
:with_desc("lsp: Show outgoing calls"),
["n|<leader>lv"] = map_callback(function()
_toggle_diagnostic()
end)
:with_noremap()
:with_silent()
:with_desc("lsp: Toggle virtual text display of current buffer"),
["n|<leader>lh"] = map_callback(function()
_toggle_inlayhint()
end)
:with_noremap()
:with_silent()
:with_desc("lsp: Toggle inlay hints dispaly of current buffer"),
}
bind.nvim_load_mapping(map)

Expand Down
24 changes: 5 additions & 19 deletions lua/keymap/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ local mappings = {
:with_silent()
:with_desc("edit: Clear search highlight"),
["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"),

-- Builtins: Lsp
["n|<leader>td"] = map_callback(function()
_toggle_diagnostic()
end)
:with_noremap()
:with_silent()
:with_desc("edit: Toggle global display of virtual text"),
["n|<leader>th"] = map_callback(function()
_toggle_inlayhint()
end)
:with_noremap()
:with_silent()
:with_desc("edit: Toggle global display of inlay hints"),
},
plugins = {
-- Plugin: persisted.nvim
Expand Down Expand Up @@ -116,27 +102,27 @@ local mappings = {
["nv|<leader>c"] = map_cmd("<Cmd>HopChar1MW<CR>"):with_noremap():with_desc("jump: Goto one char"),
["nv|<leader>C"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),

-- Plugin: nvim-spectre
-- Plugin: grug-far
["n|<leader>Ss"] = map_callback(function()
require("spectre").toggle()
require("grug-far").open()
end)
:with_silent()
:with_noremap()
:with_desc("editn: Toggle search & replace panel"),
["n|<leader>Sp"] = map_callback(function()
require("spectre").open_visual({ select_word = true })
require("grug-far").open({ prefills = { search = vim.fn.expand("<cword>") } })
end)
:with_silent()
:with_noremap()
:with_desc("editn: search&replace current word (project)"),
["v|<leader>Sp"] = map_callback(function()
require("spectre").open_visual()
require("grug-far").with_visual_selection()
end)
:with_silent()
:with_noremap()
:with_desc("edit: search & replace current word (project)"),
["n|<leader>Sf"] = map_callback(function()
require("spectre").open_file_search({ select_word = true })
require("grug-far").open({ prefills = { paths = vim.fn.expand("%") } })
end)
:with_silent()
:with_noremap()
Expand Down
86 changes: 24 additions & 62 deletions lua/keymap/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ _G._telescope_collections = function(picker_type)
:find()
end

_G._toggle_inlayhint = function()
local is_enabled = vim.lsp.inlay_hint.is_enabled()

vim.lsp.inlay_hint.enable(not is_enabled)
vim.notify(
(is_enabled and "Inlay hint disabled successfully" or "Inlay hint enabled successfully"),
vim.log.levels.INFO,
{ title = "LSP Inlay Hint" }
)
end

local _vt_enabled = require("core.settings").diagnostics_virtual_text
_G._toggle_diagnostic = function()
if vim.diagnostic.is_enabled() then
_vt_enabled = not _vt_enabled
vim.diagnostic[_vt_enabled and "show" or "hide"]()
vim.notify(
(_vt_enabled and "Virtual text is now displayed" or "Virtual text is now hidden"),
vim.log.levels.INFO,
{ title = "LSP Diagnostic" }
)
end
end

_G._flash_esc_or_noh = function()
local flash_active, state = pcall(function()
return require("flash.plugins.char").state
Expand Down Expand Up @@ -65,65 +89,3 @@ _G._toggle_lazygit = function()
vim.notify("Command [lazygit] not found!", vim.log.levels.ERROR, { title = "toggleterm.nvim" })
end
end

_G._toggle_inlayhint = function()
if vim.lsp.inlay_hint.is_enabled() then
vim.lsp.inlay_hint.enable(false)
vim.notify("Disable inlay hint successfully!", vim.log.levels.INFO, { title = "LSP Inlay Hint" })
else
vim.lsp.inlay_hint.enable(true)
vim.notify("Enable inlay hint successfully!", vim.log.levels.INFO, { title = "LSP Inlay Hint" })
end
end

local _diagnostic = 1
_G._toggle_diagnostic = function()
if vim.diagnostic.is_enabled() then
if _diagnostic == 1 then
_diagnostic = 0
vim.diagnostic.hide()
vim.notify("Hide virtual text successfully!", vim.log.levels.INFO, { title = "LSP Diagnostic" })
else
_diagnostic = 1
vim.diagnostic.show()
vim.notify("Show virtual text successfully!", vim.log.levels.INFO, { title = "LSP Diagnostic" })
end
end
end

_G._async_compile_and_debug = function()
local file_ext = vim.fn.expand("%:e")
local file_path = vim.fn.expand("%:p")
local out_name = vim.fn.expand("%:p:h") .. "/" .. vim.fn.expand("%:t:r") .. ".out"
local compile_cmd
if file_ext == "cpp" or file_ext == "cc" then
compile_cmd = string.format("g++ -g %s -o %s", file_path, out_name)
elseif file_ext == "c" then
compile_cmd = string.format("gcc -g %s -o %s", file_path, out_name)
elseif file_ext == "go" then
compile_cmd = string.format("go build -o %s %s", out_name, file_path)
else
require("dap").continue()
return
end
local notify_title = "Debug Pre-compile"
vim.fn.jobstart(compile_cmd, {
on_exit = function(_, exit_code, _)
if exit_code == 0 then
vim.notify(
"Compilation succeeded! Executable: " .. out_name,
vim.log.levels.INFO,
{ title = notify_title }
)
require("dap").continue()
return
else
vim.notify(
"Compilation failed with exit code: " .. exit_code,
vim.log.levels.ERROR,
{ title = notify_title }
)
end
end,
})
end
2 changes: 1 addition & 1 deletion lua/keymap/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ local mappings = {

-- Plugin: dap
["n|<F6>"] = map_callback(function()
_async_compile_and_debug()
require("dap").continue()
end)
:with_noremap()
:with_silent()
Expand Down
116 changes: 65 additions & 51 deletions lua/keymap/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local bind = require("keymap.bind")
local map_cr = bind.map_cr
local map_cu = bind.map_cu
local map_cmd = bind.map_cmd
local map_callback = bind.map_callback

local mappings = {
builtins = {
Expand Down Expand Up @@ -86,70 +87,83 @@ bind.nvim_load_mapping(mappings.plugins)

local M = {}

function M.gitsigns(buf)
local actions = require("gitsigns.actions")
function M.gitsigns(bufnr)
local gitsigns = require("gitsigns")
local map = {
["n|]g"] = bind.map_callback(function()
if vim.wo.diff then
return "]g"
end
vim.schedule(function()
actions.next_hunk()
["n|]g"] = map_callback(function()
if vim.wo.diff then
return "]g"
end
vim.schedule(function()
gitsigns.nav_hunk("next")
end)
return "<Ignore>"
end)
return "<Ignore>"
end)
:with_buffer(buf)
:with_buffer(bufnr)
:with_noremap()
:with_expr()
:with_desc("git: Goto next hunk"),
["n|[g"] = bind.map_callback(function()
if vim.wo.diff then
return "[g"
end
vim.schedule(function()
actions.prev_hunk()
["n|[g"] = map_callback(function()
if vim.wo.diff then
return "[g"
end
vim.schedule(function()
gitsigns.nav_hunk("prev")
end)
return "<Ignore>"
end)
return "<Ignore>"
end)
:with_buffer(buf)
:with_buffer(bufnr)
:with_noremap()
:with_expr()
:with_desc("git: Goto prev hunk"),
["n|<leader>gs"] = bind.map_callback(function()
actions.stage_hunk()
end)
:with_buffer(buf)
:with_desc("git: Stage hunk"),
["v|<leader>gs"] = bind.map_callback(function()
actions.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(buf)
:with_desc("git: Stage hunk"),
["n|<leader>gr"] = bind.map_callback(function()
actions.reset_hunk()
end)
:with_buffer(buf)
["n|<leader>gs"] = map_callback(function()
gitsigns.stage_hunk()
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Toggle staging/unstaging of hunk"),
["v|<leader>gs"] = map_callback(function()
gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Toggle staging/unstaging of selected hunk"),
["n|<leader>gr"] = map_callback(function()
gitsigns.reset_hunk()
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Reset hunk"),
["v|<leader>gr"] = bind.map_callback(function()
actions.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(buf)
["v|<leader>gr"] = map_callback(function()
gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Reset hunk"),
["n|<leader>gR"] = bind.map_callback(function()
actions.reset_buffer()
end)
:with_buffer(buf)
["n|<leader>gR"] = map_callback(function()
gitsigns.reset_buffer()
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Reset buffer"),
["n|<leader>gp"] = bind.map_callback(function()
actions.preview_hunk()
end)
:with_buffer(buf)
["n|<leader>gp"] = map_callback(function()
gitsigns.preview_hunk()
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Preview hunk"),
["n|<leader>gb"] = bind.map_callback(function()
actions.blame_line({ full = true })
end)
:with_buffer(buf)
["n|<leader>gb"] = map_callback(function()
gitsigns.blame_line({ full = true })
end)
:with_buffer(bufnr)
:with_noremap()
:with_desc("git: Blame line"),
-- Text objects
["ox|ih"] = bind.map_cu("Gitsigns select_hunk"):with_silent():with_buffer(buf),
["ox|ih"] = map_callback(function()
gitsigns.select_hunk()
end)
:with_buffer(bufnr)
:with_noremap(),
}
bind.nvim_load_mapping(map)
end
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/servers/bashls.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/bashls.lua
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/bashls.lua
return {
cmd = { "bash-language-server", "start" },
filetypes = { "bash", "sh" },
Expand Down
Loading

0 comments on commit c732ca3

Please sign in to comment.