mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-07 22:48:00 -08:00
replace nvim submodule with real files
This commit is contained in:
3
.config/nvim/lua/utils/extensions/init.lua
Normal file
3
.config/nvim/lua/utils/extensions/init.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
require("utils.extensions.telescope"),
|
||||
}
|
||||
7
.config/nvim/lua/utils/extensions/telescope/init.lua
Normal file
7
.config/nvim/lua/utils/extensions/telescope/init.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
local ts = require("telescope")
|
||||
ts.load_extension("fzf")
|
||||
ts.load_extension("color_names")
|
||||
ts.load_extension("file_browser")
|
||||
ts.load_extension("glyph")
|
||||
ts.load_extension("ui-select")
|
||||
ts.load_extension("noice")
|
||||
57
.config/nvim/lua/utils/git_paste/init.lua
Normal file
57
.config/nvim/lua/utils/git_paste/init.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
local M = {}
|
||||
|
||||
--- Fetches the content from the given URL and then pastes the contents below the current line.
|
||||
---@param url string The URL to fetch (expects a Git raw URL).
|
||||
function M.fetch_and_paste(url)
|
||||
if not url or url == "" then
|
||||
vim.notify("git-paste: No URL provided.", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
-- Use curl to fetch the raw file content
|
||||
local result = vim.fn.system({ "curl", "-s", url })
|
||||
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.notify("git-paste: Failed to fetch content from URL:\n" .. result, vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
-- Split the result into lines. This creates a table with each line.
|
||||
local lines = vim.split(result, "\n")
|
||||
|
||||
-- Get the current cursor position. This returns a table {line, col}
|
||||
-- Nvim's API for setting lines expects 0-indexed line numbers.
|
||||
local pos = vim.api.nvim_win_get_cursor(0)
|
||||
-- Insert the fetched lines after the current cursor line.
|
||||
-- Since pos[1] is 1-indexed, we use it directly as the insertion index (which is 0-indexed)
|
||||
-- when inserting *after* the current line.
|
||||
local insert_at = pos[1]
|
||||
vim.api.nvim_buf_set_lines(0, insert_at, insert_at, false, lines)
|
||||
|
||||
vim.notify("git-paste: Content pasted successfully", vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
--- Prompts the user for a Git raw URL and then pastes the fetched content.
|
||||
function M.git_paste_prompt()
|
||||
vim.ui.input({ prompt = "Git raw URL: " }, function(input)
|
||||
if input then
|
||||
M.fetch_and_paste(input)
|
||||
else
|
||||
vim.notify("git-paste: No URL provided", vim.log.levels.WARN)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
--- Sets up the git-paste module.
|
||||
---
|
||||
--- The module expects an optional configuration table:
|
||||
--- { telescope_key = "<leader>pg" } (or any other keymap you prefer)
|
||||
---
|
||||
---@param opts table|nil
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
local telescope_key = opts.telescope_key or "<leader>pg"
|
||||
vim.keymap.set("n", telescope_key, M.git_paste_prompt, { desc = "Git Paste: paste content from git raw URL" })
|
||||
end
|
||||
|
||||
return M
|
||||
102
.config/nvim/lua/utils/hyprland/lsp/init.lua
Normal file
102
.config/nvim/lua/utils/hyprland/lsp/init.lua
Normal file
@@ -0,0 +1,102 @@
|
||||
vim.notify = require("notify")
|
||||
|
||||
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][token] then
|
||||
client_notifs[client_id][token] = {}
|
||||
end
|
||||
|
||||
return client_notifs[client_id][token]
|
||||
end
|
||||
|
||||
local spinner_frames = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }
|
||||
|
||||
local function update_spinner(client_id, token)
|
||||
local notif_data = get_notif_data(client_id, token)
|
||||
|
||||
if notif_data.spinner then
|
||||
local new_spinner = (notif_data.spinner + 1) % #spinner_frames
|
||||
notif_data.spinner = new_spinner
|
||||
|
||||
notif_data.notification = vim.notify("", nil, {
|
||||
hide_from_history = true,
|
||||
icon = spinner_frames[new_spinner],
|
||||
replace = notif_data.notification,
|
||||
})
|
||||
|
||||
vim.defer_fn(function()
|
||||
update_spinner(client_id, token)
|
||||
end, 100)
|
||||
end
|
||||
end
|
||||
|
||||
local function format_title(title, client_name)
|
||||
return client_name .. (#title > 0 and ": " .. title or "")
|
||||
end
|
||||
|
||||
local function format_message(message, percentage)
|
||||
return (percentage and percentage .. "%\t" or "") .. (message or "")
|
||||
end
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
pattern = { "*.hl", "hypr*.conf" },
|
||||
callback = function(event)
|
||||
-- print(string.format("starting hyprls for %s", vim.inspect(event)))
|
||||
vim.lsp.start({
|
||||
name = "hyprlang",
|
||||
cmd = { "hyprls" },
|
||||
root_dir = vim.fn.getcwd(),
|
||||
on_attach = function()
|
||||
vim.notify("Hyprlang LSP attached", "info")
|
||||
end,
|
||||
on_init = function()
|
||||
vim.notify("Hyprlang LSP initialized", "info")
|
||||
end,
|
||||
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 = 3000,
|
||||
})
|
||||
|
||||
notif_data.spinner = nil
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
local M = {}
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
function M.set_keybindings(bindings)
|
||||
for _, binding in ipairs(bindings) do
|
||||
map(binding.mode, binding.key, binding.cmd, binding.opts or opts)
|
||||
end
|
||||
return bindings
|
||||
end
|
||||
|
||||
return M
|
||||
48
.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua
Normal file
48
.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
local M = {}
|
||||
|
||||
local whichkey = require("which-key")
|
||||
vim.notify = require("notify")
|
||||
|
||||
---Helper function to add mappings to which-key
|
||||
---@parm mappings table : List of mappings to add to which-key
|
||||
---@parm group table : Group to add mappings to (optional)
|
||||
---@return nil
|
||||
---@usage addToWhichKey(mappings, group)
|
||||
---@example addToWhichKey({{key = "n", cmd = "next", mode = "n", desc = "Next Line", group = "Navigation"}, {key = "t", group = "example"})
|
||||
function M.addToWhichKey(mappings, group)
|
||||
local wk_mappings = {}
|
||||
if group then
|
||||
whichkey.add({ group.key, group = group.group })
|
||||
end
|
||||
if not mappings and not group then
|
||||
vim.notify("Error: Mappings is nil", "error")
|
||||
return
|
||||
elseif not mappings and group then
|
||||
return
|
||||
end
|
||||
for _, mapping in ipairs(mappings) do
|
||||
if not mapping.key or mapping.key == "" then
|
||||
vim.notify("Error: Key is empty or nil", "error")
|
||||
return
|
||||
end
|
||||
|
||||
if not mapping.cmd or mapping.cmd == "" then
|
||||
vim.notify("Error: Command is empty or nil for key: " .. mapping.key, "error")
|
||||
return
|
||||
end
|
||||
|
||||
if not mapping.mode or mapping.mode == "" then
|
||||
vim.notify("Error: Mode is empty or nil for key: " .. mapping.key, "error")
|
||||
return
|
||||
end
|
||||
|
||||
wk_mappings[1] = mapping.key
|
||||
wk_mappings[2] = mapping.cmd
|
||||
wk_mappings.mode = mapping.mode
|
||||
wk_mappings.desc = mapping.desc or "No Description"
|
||||
wk_mappings.group = mapping.group or "No Group"
|
||||
whichkey.add(wk_mappings)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
4
.config/nvim/lua/utils/keymaps/init.lua
Normal file
4
.config/nvim/lua/utils/keymaps/init.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
return {
|
||||
require('utils.keymaps.converters.whichkey'),
|
||||
require('utils.keymaps.converters.from_table'),
|
||||
}
|
||||
68
.config/nvim/lua/utils/telescope_extra/init.lua
Normal file
68
.config/nvim/lua/utils/telescope_extra/init.lua
Normal file
@@ -0,0 +1,68 @@
|
||||
local telescope = require("telescope")
|
||||
local telescopeConfig = require("telescope.config")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
-- Clone the default Telescope configuration
|
||||
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
|
||||
|
||||
-- I want to search in hidden/dot files.
|
||||
table.insert(vimgrep_arguments, "--hidden")
|
||||
-- I don't want to search in the `.git` directory.
|
||||
table.insert(vimgrep_arguments, "--glob")
|
||||
table.insert(vimgrep_arguments, "!**/.git/*")
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
-- `hidden = true` is not supported in text grep commands.
|
||||
vimgrep_arguments = vimgrep_arguments,
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
|
||||
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
||||
mappings = {
|
||||
n = {
|
||||
["cd"] = function(prompt_bufnr)
|
||||
local selection = require("telescope.actions.state").get_selected_entry()
|
||||
local dir = vim.fn.fnamemodify(selection.path, ":p:h")
|
||||
require("telescope.actions").close(prompt_bufnr)
|
||||
-- Depending on what you want put `cd`, `lcd`, `tcd`
|
||||
vim.cmd(string.format("silent lcd %s", dir))
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
preview = {
|
||||
-- show images in telescope using kitty
|
||||
mime_hook = function(filepath, bufnr, opts)
|
||||
local is_image = function(filepath)
|
||||
local image_extensions = { "png", "jpg" } -- Supported image formats
|
||||
local split_path = vim.split(filepath:lower(), ".", { plain = true })
|
||||
local extension = split_path[#split_path]
|
||||
return vim.tbl_contains(image_extensions, extension)
|
||||
end
|
||||
if is_image(filepath) then
|
||||
local term = vim.api.nvim_open_term(bufnr, {})
|
||||
local function send_output(_, data, _)
|
||||
for _, d in ipairs(data) do
|
||||
vim.api.nvim_chan_send(term, d .. "\r\n")
|
||||
end
|
||||
end
|
||||
vim.fn.jobstart({
|
||||
"kitty +icat " .. filepath, -- Terminal image viewer command
|
||||
}, { on_stdout = send_output, stdout_buffered = true, pty = true })
|
||||
else
|
||||
require("telescope.previewers.utils").set_preview_message(
|
||||
bufnr,
|
||||
opts.winid,
|
||||
"Binary cannot be previewed"
|
||||
)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
6
.config/nvim/lua/utils/terminal/init.lua
Normal file
6
.config/nvim/lua/utils/terminal/init.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
M.term_factory = require("utils.terminal.term_factory").term_factory
|
||||
M.term_toggle = require("utils.terminal.toggle").term_toggle
|
||||
|
||||
return M
|
||||
12
.config/nvim/lua/utils/terminal/term_factory/init.lua
Normal file
12
.config/nvim/lua/utils/terminal/term_factory/init.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local notify = require("notify")
|
||||
local M = {}
|
||||
|
||||
function M.term_factory(cfg)
|
||||
cfg["on_stderr"] = function(_, job, data, name)
|
||||
notify(name .. " encountered an error on job: " .. job .. "\nData: " .. data, "error")
|
||||
end
|
||||
return Terminal:new(cfg)
|
||||
end
|
||||
|
||||
return M
|
||||
9
.config/nvim/lua/utils/terminal/toggle/init.lua
Normal file
9
.config/nvim/lua/utils/terminal/toggle/init.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
local M = {}
|
||||
|
||||
function M.term_toggle(term)
|
||||
if term then
|
||||
term:toggle()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
15
.config/nvim/lua/utils/treesitter/parsers/hyprlang/init.lua
Normal file
15
.config/nvim/lua/utils/treesitter/parsers/hyprlang/init.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
parser_config.hyprlang = {
|
||||
install_info = {
|
||||
url = "~/github/tree-sitter-hyprlang", -- local path or git repo
|
||||
files = { "src/parser.c" }, -- note that some parsers also require src/scanner.c or src/scanner.cc
|
||||
-- optional entries:
|
||||
branch = "main", -- default branch in case of git repo if different from master
|
||||
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
|
||||
requires_generate_from_grammar = true, -- if folder contains pre-generated src/parser.c
|
||||
},
|
||||
filetype = "conf", -- if filetype does not match the parser name
|
||||
}
|
||||
vim.filetype.add({
|
||||
pattern = { [".*/hypr/.*%.conf"] = "hyprlang" },
|
||||
})
|
||||
Reference in New Issue
Block a user