Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catppuccin mocha #5

Merged
merged 36 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add utils
  • Loading branch information
wochap committed Sep 6, 2023
commit 0bc2fb219d0561ced4fb61c562143f26a01f42e5
3 changes: 3 additions & 0 deletions lua/custom/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ M.git = {
M.persistence = {
n = {
["<leader>nl"] = { "<cmd>lua require('persistence').load()<CR>", "load last session" },
["<f2>"] = { "<cmd>lua require('base46').load_all_highlights()<CR>", "load custom theme without cache?" },
["<f3>"] = { "<cmd>lua require'custom.utils.others'.printSyntaxInfo()<CR>", "print syntax info" },
["<f4>"] = { "<cmd>lua require'custom.utils.others'.printBufInfo()<CR>", "print buffer info" },
},
}

Expand Down
33 changes: 33 additions & 0 deletions lua/custom/utils/others.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,37 @@ M.expandSnippet = function()
end
end

M.printSyntaxInfo = function()
local line = vim.fn.line "."
local col = vim.fn.col "."

-- Get the syntax ID of the character under the cursor
local syn_id_start = vim.fn.synID(line, col, 1)
local syn_id_end = vim.fn.synID(line, col, 0)

-- Get the syntax names for the IDs
local syn_name_start = vim.fn.synIDattr(syn_id_start, "name")
local syn_name_end = vim.fn.synIDattr(syn_id_end, "name")

-- Get the syntax name after translation
local syn_trans_id = vim.fn.synIDtrans(syn_id_start)
local syn_trans_name = vim.fn.synIDattr(syn_trans_id, "name")

print("hi<" .. syn_name_start .. ">")
print("trans<" .. syn_name_end .. ">")
print("lo<" .. syn_trans_name .. ">")
end

M.printBufInfo = function()
local winid = vim.api.nvim_get_current_win()
local bufid = vim.api.nvim_win_get_buf(winid)
local buftype = vim.api.nvim_buf_get_option(bufid, "buftype")
local bufname = vim.api.nvim_buf_get_name(bufid)

print("winid " .. winid)
print("bufid " .. bufid)
print("buftype " .. buftype)
print("bufname " .. bufname)
end

return M