mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-05 02:53:38 -08:00
update nvim
This commit is contained in:
@@ -2,6 +2,7 @@ local map = vim.keymap.set
|
||||
local term = require("utils.terminal")
|
||||
local map_from_table = require("utils.keymaps.converters.from_table").set_keybindings
|
||||
local add_to_whichkey = require("utils.keymaps.converters.whichkey").addToWhichKey
|
||||
local telescope_paste_img = require("utils.telescope_extra").find_and_paste_image
|
||||
local term_factory = term.term_factory
|
||||
local term_toggle = term.term_toggle
|
||||
|
||||
@@ -34,7 +35,7 @@ local basic_mappings = {
|
||||
{ key = "<C-u>", cmd = "<C-u>zz", desc = "Scroll up and center", mode = "n" },
|
||||
{ key = "n", cmd = "nzzzv", desc = "Next search result and center", mode = "n" },
|
||||
{ key = "N", cmd = "Nzzzv", desc = "Previous search result and center", mode = "n" },
|
||||
{ key = "<leader>p", cmd = '"_dP', desc = "Paste without yanking", mode = "x", group = "Paste in place" },
|
||||
{ key = "<leader>pp", cmd = '"_dP', desc = "Paste without yanking", mode = "x" },
|
||||
{ key = "<", cmd = "<gv", desc = "Reselect after indent", mode = "v" },
|
||||
{ key = ">", cmd = ">gv", desc = "Reselect after indent", mode = "v" },
|
||||
{ key = "J", cmd = ":m '>+1<CR>gv=gv", desc = "Move line down", mode = "v" },
|
||||
@@ -200,6 +201,7 @@ local lsp_mappings = {
|
||||
group = "Goto Previous Preview",
|
||||
},
|
||||
{ mode = "n", key = "<leader>cl", cmd = ":lua vim.diagnostic.setloclist()<CR>", group = "Set Loclist" },
|
||||
{ mode = "n", key = "<leader>Clr", cmd = ":LspRestart<CR>", group = "Restart LSP" },
|
||||
{
|
||||
mode = "n",
|
||||
key = "<leader>cPs",
|
||||
@@ -230,7 +232,7 @@ local code_companion_mappings = {
|
||||
mode = "v",
|
||||
key = "<leader>Ci",
|
||||
cmd = ":CodeCompanion #{buffer} ",
|
||||
group = "CodeCompanion #{buffer}",
|
||||
group = "CodeCompanion Inline",
|
||||
opts = nosilent,
|
||||
},
|
||||
{ mode = "v", key = "<leader>Ce", cmd = ":CodeCompanion /explain<CR>", group = "CodeCompanion /explain" },
|
||||
@@ -284,6 +286,14 @@ local telescope_mappings = {
|
||||
cmd = ":Telescope noice theme=dropdown layout_config={width=0.75}<CR>",
|
||||
group = "Telescope Noice",
|
||||
},
|
||||
{
|
||||
mode = "n",
|
||||
key = "<leader>Ti",
|
||||
cmd = function()
|
||||
telescope_paste_img()
|
||||
end,
|
||||
desc = "Find and Paste Image",
|
||||
},
|
||||
{
|
||||
mode = "n",
|
||||
key = "<leader>ff",
|
||||
@@ -528,7 +538,7 @@ end
|
||||
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
|
||||
--}}}
|
||||
|
||||
-- {{{ NVIM-IMAGE
|
||||
-- {{{ IMAGE
|
||||
local image_mappings = {
|
||||
{
|
||||
|
||||
@@ -544,6 +554,14 @@ local image_mappings = {
|
||||
cmd = ":lua require('image').enable()<CR>",
|
||||
desc = "Enable image rendering",
|
||||
},
|
||||
{
|
||||
mode = "n",
|
||||
key = "<leader>pi",
|
||||
cmd = function()
|
||||
telescope_paste_img()
|
||||
end,
|
||||
desc = "Find and Paste Image",
|
||||
},
|
||||
}
|
||||
-- }}}
|
||||
|
||||
@@ -554,6 +572,7 @@ add_to_whichkey(nil, { key = "<leader>c", group = "Code" })
|
||||
add_to_whichkey(nil, { key = "<leader>ca", group = "Code Actions" })
|
||||
add_to_whichkey(nil, { key = "<leader>cc", group = "Calls" })
|
||||
add_to_whichkey(nil, { key = "<leader>C", group = "CodeCompanion" })
|
||||
add_to_whichkey(nil, { key = "<leader>cL", group = "LSP" })
|
||||
add_to_whichkey(nil, { key = "<leader>d", group = "ODIS" })
|
||||
add_to_whichkey(nil, { key = "<leader>f", group = "Find" })
|
||||
add_to_whichkey(nil, { key = "<leader>g", group = "Git" })
|
||||
@@ -563,7 +582,8 @@ add_to_whichkey(nil, { key = "<leader>i", group = "Image" })
|
||||
add_to_whichkey(nil, { key = "<leader>j", group = "AnyJump" })
|
||||
add_to_whichkey(nil, { key = "<leader>N", group = "Noice" })
|
||||
-- add_to_whichkey(nil, { key = "<leader>o", group = "Open" })
|
||||
add_to_whichkey(nil, { key = "<leader>p", group = "Paste in Place" })
|
||||
add_to_whichkey(nil, { key = "<leader>p", group = "Paste" })
|
||||
add_to_whichkey(nil, { key = "<leader>pg", group = "Paste Git Raw" })
|
||||
add_to_whichkey(nil, { key = "<leader>s", group = "Search" })
|
||||
add_to_whichkey(nil, { key = "<leader>t", group = "Terminal" })
|
||||
add_to_whichkey(nil, { key = "<leader>T", group = "Telescope" })
|
||||
|
||||
@@ -4,7 +4,40 @@ return {
|
||||
priority = 1000,
|
||||
opts = {
|
||||
flavour = "macchiato", -- latte, frappe, macchiato, mocha
|
||||
transparent_background = false, -- disables setting the background color.
|
||||
float = {
|
||||
transparent = false, -- enable transparent floating windows
|
||||
solid = false, -- use solid styling for floating windows, see |winborder|
|
||||
},
|
||||
show_end_of_buffer = false, -- shows the '~' characters after the end of buffers
|
||||
term_colors = true, -- sets terminal colors (e.g. `g:terminal_color_0`)
|
||||
dim_inactive = {
|
||||
enabled = false, -- dims the background color of inactive window
|
||||
shade = "dark",
|
||||
percentage = 0.15, -- percentage of the shade to apply to the inactive window
|
||||
},
|
||||
no_italic = false, -- Force no italic
|
||||
no_bold = false, -- Force no bold
|
||||
no_underline = false, -- Force no underline
|
||||
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
|
||||
comments = { "italic" }, -- Change the style of comments
|
||||
conditionals = { "italic" },
|
||||
loops = { "bold" },
|
||||
functions = { "bold", "italic" },
|
||||
keywords = { "bold" },
|
||||
strings = {},
|
||||
variables = { "bold" },
|
||||
numbers = { "bold" },
|
||||
booleans = { "bold" },
|
||||
properties = { "bold" },
|
||||
types = { "bold" },
|
||||
operators = { "bold" },
|
||||
-- miscs = {}, -- Uncomment to turn off hard-coded styles
|
||||
},
|
||||
color_overrides = {},
|
||||
custom_highlights = {},
|
||||
default_integrations = true,
|
||||
auto_integrations = false,
|
||||
integrations = {
|
||||
cmp = true,
|
||||
gitsigns = true,
|
||||
@@ -15,7 +48,9 @@ return {
|
||||
},
|
||||
bufferline = true,
|
||||
dashboard = true,
|
||||
diffview = true,
|
||||
fidget = true,
|
||||
noice = true,
|
||||
indent_blankline = {
|
||||
enabled = true,
|
||||
scope_color = "lavendar", -- catppuccin color (eg. `lavender`) Default: text
|
||||
@@ -45,12 +80,13 @@ return {
|
||||
notify = true,
|
||||
treesitter = true,
|
||||
rainbow_delimiters = true,
|
||||
render_markdown = true,
|
||||
telescope = {
|
||||
enabled = true,
|
||||
-- style = "nvchad"
|
||||
},
|
||||
which_key = true
|
||||
which_key = true,
|
||||
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ return {
|
||||
},
|
||||
opts = {
|
||||
adapters = {
|
||||
-- {{{ HTTP
|
||||
http = {
|
||||
-- {{{ COPILOT
|
||||
copilot = function()
|
||||
return require("codecompanion.adapters").extend("copilot", {
|
||||
schema = {
|
||||
@@ -45,6 +48,8 @@ return {
|
||||
},
|
||||
})
|
||||
end,
|
||||
-- }}}
|
||||
-- {{{ LLAMA_CPP
|
||||
llama_cpp = function()
|
||||
return require("codecompanion.adapters").extend("openai_compatible", {
|
||||
name = "llama.cpp",
|
||||
@@ -82,6 +87,8 @@ return {
|
||||
},
|
||||
})
|
||||
end,
|
||||
-- }}}
|
||||
-- {{{ OPENROUTER
|
||||
openrouter = function()
|
||||
return require("codecompanion.adapters").extend("openai_compatible", {
|
||||
env = {
|
||||
@@ -100,6 +107,22 @@ return {
|
||||
},
|
||||
})
|
||||
end,
|
||||
-- }}}
|
||||
},
|
||||
-- }}}
|
||||
-- {{{ ACP
|
||||
acp = {
|
||||
gemini_cli = function()
|
||||
return require("codecompanion.adapters").extend("gemini_cli", {
|
||||
defaults = {
|
||||
auth_method = "oauth-personal", -- "oauth-personal"|"gemini-api-key"|"vertex-ai"
|
||||
mcpServers = {},
|
||||
timeout = 20000, -- 20 seconds
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
-- }}}
|
||||
},
|
||||
strategies = {
|
||||
chat = {
|
||||
@@ -212,6 +235,7 @@ return {
|
||||
},
|
||||
},
|
||||
init = function()
|
||||
require("plugins.codecompanion.fidget-spinner"):init()
|
||||
require("utils.codecompanion.fidget-spinner"):init()
|
||||
require("utils.codecompanion.extmarks").setup()
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
return {
|
||||
"zbirenbaum/copilot.lua",
|
||||
cmd = "Copilot",
|
||||
event = "InsertEnter",
|
||||
opts = {
|
||||
panel = {
|
||||
enabled = true,
|
||||
@@ -49,7 +51,29 @@ return {
|
||||
listCount = 10, -- #completions for panel
|
||||
inlineSuggestCount = 5, -- #completions for getCompletions
|
||||
},
|
||||
telemetry = {
|
||||
telemetryLevel = "all",
|
||||
},
|
||||
},
|
||||
},
|
||||
copilot_node_command = "node", -- Node.js version must be > 20
|
||||
workspace_folders = {},
|
||||
-- copilot_model = "",
|
||||
disable_limit_reached_message = false, -- Set to `true` to suppress completion limit reached popup
|
||||
logger = {
|
||||
file = vim.fn.stdpath("log") .. "/copilot-lua.log",
|
||||
file_log_level = vim.log.levels.OFF,
|
||||
print_log_level = vim.log.levels.WARN,
|
||||
trace_lsp = "off", -- "off" | "messages" | "verbose"
|
||||
trace_lsp_progress = false,
|
||||
log_lsp_messages = false,
|
||||
},
|
||||
root_dir = function()
|
||||
return vim.fs.dirname(vim.fs.find(".git", { upward = true })[1])
|
||||
end,
|
||||
server = {
|
||||
type = "nodejs", -- "nodejs" | "binary"
|
||||
custom_server_filepath = nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
113
.config/nvim/lua/plugins/img-clip.lua
Normal file
113
.config/nvim/lua/plugins/img-clip.lua
Normal file
@@ -0,0 +1,113 @@
|
||||
return {
|
||||
"HakonHarnes/img-clip.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
default = {
|
||||
-- file and directory options
|
||||
dir_path = function()
|
||||
return vim.fn.expand("%:t:r")
|
||||
end, ---@type string | fun(): string
|
||||
extension = "png", ---@type string | fun(): string
|
||||
file_name = "%Y-%m-%d-%H-%M-%S", ---@type string | fun(): string
|
||||
use_absolute_path = false, ---@type boolean | fun(): boolean
|
||||
relative_to_current_file = false, ---@type boolean | fun(): boolean
|
||||
|
||||
-- logging options
|
||||
verbose = true, ---@type boolean | fun(): boolean
|
||||
|
||||
-- template options
|
||||
template = "$FILE_PATH", ---@type string | fun(context: table): string
|
||||
url_encode_path = false, ---@type boolean | fun(): boolean
|
||||
relative_template_path = true, ---@type boolean | fun(): boolean
|
||||
use_cursor_in_template = true, ---@type boolean | fun(): boolean
|
||||
insert_mode_after_paste = true, ---@type boolean | fun(): boolean
|
||||
insert_template_after_cursor = true, ---@type boolean | fun(): boolean
|
||||
|
||||
-- prompt options
|
||||
prompt_for_file_name = true, ---@type boolean | fun(): boolean
|
||||
show_dir_path_in_prompt = false, ---@type boolean | fun(): boolean
|
||||
|
||||
-- base64 options
|
||||
max_base64_size = 10, ---@type number | fun(): number
|
||||
embed_image_as_base64 = false, ---@type boolean | fun(): boolean
|
||||
|
||||
-- image options
|
||||
process_cmd = "", ---@type string | fun(): string
|
||||
copy_images = false, ---@type boolean | fun(): boolean
|
||||
download_images = true, ---@type boolean | fun(): boolean
|
||||
|
||||
-- drag and drop options
|
||||
drag_and_drop = {
|
||||
enabled = true, ---@type boolean | fun(): boolean
|
||||
insert_mode = false, ---@type boolean | fun(): boolean
|
||||
},
|
||||
},
|
||||
|
||||
-- filetype specific options
|
||||
filetypes = {
|
||||
markdown = {
|
||||
url_encode_path = true, ---@type boolean | fun(): boolean
|
||||
template = "", ---@type string | fun(context: table): string
|
||||
download_images = false, ---@type boolean | fun(): boolean
|
||||
},
|
||||
|
||||
vimwiki = {
|
||||
url_encode_path = true, ---@type boolean | fun(): boolean
|
||||
template = "", ---@type string | fun(context: table): string
|
||||
download_images = false, ---@type boolean | fun(): boolean
|
||||
},
|
||||
|
||||
html = {
|
||||
template = '<img src="$FILE_PATH" alt="$CURSOR">', ---@type string | fun(context: table): string
|
||||
},
|
||||
|
||||
tex = {
|
||||
relative_template_path = false, ---@type boolean | fun(): boolean
|
||||
template = [[
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\includegraphics[width=0.8\textwidth]{$FILE_PATH}
|
||||
\caption{$CURSOR}
|
||||
\label{fig:$LABEL}
|
||||
\end{figure}
|
||||
]], ---@type string | fun(context: table): string
|
||||
},
|
||||
|
||||
typst = {
|
||||
template = [[
|
||||
#figure(
|
||||
image("$FILE_PATH", width: 80%),
|
||||
caption: [$CURSOR],
|
||||
) <fig-$LABEL>
|
||||
]], ---@type string | fun(context: table): string
|
||||
},
|
||||
|
||||
rst = {
|
||||
template = [[
|
||||
.. image:: $FILE_PATH
|
||||
:alt: $CURSOR
|
||||
:width: 80%
|
||||
]], ---@type string | fun(context: table): string
|
||||
},
|
||||
|
||||
asciidoc = {
|
||||
template = 'image::$FILE_PATH[width=80%, alt="$CURSOR"]', ---@type string | fun(context: table): string
|
||||
},
|
||||
|
||||
org = {
|
||||
template = [=[
|
||||
#+BEGIN_FIGURE
|
||||
[[file:$FILE_PATH]]
|
||||
#+CAPTION: $CURSOR
|
||||
#+NAME: fig:$LABEL
|
||||
#+END_FIGURE
|
||||
]=], ---@type string | fun(context: table): string
|
||||
},
|
||||
},
|
||||
|
||||
-- file, directory, and custom triggered options
|
||||
files = {}, ---@type table | fun(): table
|
||||
dirs = {}, ---@type table | fun(): table
|
||||
custom = {}, ---@type table | fun(): table
|
||||
},
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
return {
|
||||
"ravitemer/mcphub.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
cmd = "MCPHub",
|
||||
build = "bundled_build.lua", -- Bundles mcp-hub locally
|
||||
config = function()
|
||||
vim.notify = require("notify")
|
||||
require("mcphub").setup({
|
||||
use_bundled_binary = true, -- Use local binary
|
||||
port = 37373, -- Port for MCP Hub Express API
|
||||
config = vim.fn.expand("~/.config/mcphub/servers.json"), -- Config file path
|
||||
native_servers = {}, -- add your native servers here
|
||||
auto_approve = true,
|
||||
extensions = {
|
||||
avante = {},
|
||||
codecompanion = {
|
||||
show_result_in_chat = true, -- Show tool results in chat
|
||||
make_vars = true, -- Create chat variables from resources
|
||||
make_slash_commands = true, -- make /slash_commands from MCP server prompts
|
||||
},
|
||||
},
|
||||
|
||||
-- UI configuration
|
||||
ui = {
|
||||
window = {
|
||||
width = 0.8, -- Window width (0-1 ratio)
|
||||
height = 0.8, -- Window height (0-1 ratio)
|
||||
border = "rounded", -- Window border style
|
||||
relative = "editor", -- Window positioning
|
||||
zindex = 50, -- Window stack order
|
||||
},
|
||||
},
|
||||
|
||||
-- Event callbacks
|
||||
on_ready = function(hub) end, -- Called when hub is ready
|
||||
on_error = function(err)
|
||||
vim.notify(err, "ERROR")
|
||||
end, -- Called on errors
|
||||
|
||||
-- Logging configuration
|
||||
log = {
|
||||
level = vim.log.levels.WARN, -- Minimum log level
|
||||
to_file = false, -- Enable file logging
|
||||
file_path = nil, -- Custom log file path
|
||||
prefix = "MCPHub", -- Log message prefix
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
return {
|
||||
"echasnovski/mini.diff",
|
||||
depends = { "echasnovski/mini.nvim" },
|
||||
opts = {
|
||||
config = function()
|
||||
local diff = require("mini.diff")
|
||||
diff.setup({
|
||||
|
||||
-- Options for how hunks are visualized
|
||||
view = {
|
||||
@@ -18,7 +20,7 @@ return {
|
||||
|
||||
-- Source for how reference text is computed/updated/etc
|
||||
-- Uses content from Git index by default
|
||||
source = nil,
|
||||
source = diff.gen_source.none(),
|
||||
|
||||
-- Delays (in ms) defining asynchronous processes
|
||||
delay = {
|
||||
@@ -59,5 +61,6 @@ return {
|
||||
-- Whether to wrap around edges during hunk navigation
|
||||
wrap_goto = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -171,8 +171,8 @@ return {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp_signature_help", group_index = 0 },
|
||||
{ name = "lazydev", group_index = 0 },
|
||||
{ name = "copilot", group_index = 0 },
|
||||
{ name = "nvim_lsp", group_index = 1 },
|
||||
{ name = "copilot", group_index = 1 },
|
||||
{ name = "codecompanion", group_index = 2 },
|
||||
{ name = "async_path", group_index = 2 },
|
||||
{ name = "nvim_lsp_document_symbol", group_index = 2 },
|
||||
|
||||
@@ -12,6 +12,7 @@ return {
|
||||
vim = { "vint" },
|
||||
go = { "golangcilint" },
|
||||
}
|
||||
lint.linters.jsonlint.cmd = "vscode-json-language-server"
|
||||
lint.linters.shellcheck.args = {
|
||||
"-s",
|
||||
"bash",
|
||||
|
||||
94
.config/nvim/lua/utils/codecompanion/extmarks.lua
Normal file
94
.config/nvim/lua/utils/codecompanion/extmarks.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
--- @class CodeCompanion.InlineExtmark
|
||||
--- @field unique_line_sign_text string Text used for sign when there's only a single line
|
||||
--- @field first_line_sign_text string Text used for sign on the first line of multi-line section
|
||||
--- @field last_line_sign_text string Text used for sign on the last line of multi-line section
|
||||
--- @field extmark vim.api.keyset.set_extmark Extmark options passed to nvim_buf_set_extmark
|
||||
|
||||
local M = {}
|
||||
|
||||
--- @type CodeCompanion.InlineExtmark
|
||||
local default_opts = {
|
||||
unique_line_sign_text = "",
|
||||
first_line_sign_text = "┌",
|
||||
last_line_sign_text = "└",
|
||||
extmark = {
|
||||
sign_hl_group = "DiagnosticWarn",
|
||||
sign_text = "│",
|
||||
priority = 1000,
|
||||
},
|
||||
}
|
||||
|
||||
--- Helper function to set a line extmark with specified sign text
|
||||
--- @param bufnr number
|
||||
--- @param ns_id number
|
||||
--- @param line_num number Line number
|
||||
--- @param opts vim.api.keyset.set_extmark Extmark options
|
||||
--- @param sign_type string Key in opts for the sign text to use
|
||||
local function set_line_extmark(bufnr, ns_id, line_num, opts, sign_type)
|
||||
vim.api.nvim_buf_set_extmark(
|
||||
bufnr,
|
||||
ns_id,
|
||||
line_num - 1, -- Convert to 0-based index
|
||||
0,
|
||||
vim.tbl_deep_extend("force", opts.extmark or {}, {
|
||||
sign_text = opts[sign_type] or opts.extmark.sign_text,
|
||||
})
|
||||
)
|
||||
end
|
||||
|
||||
--- Creates extmarks for inline code annotations
|
||||
--- @param opts CodeCompanion.InlineExtmark Configuration options for the extmarks
|
||||
--- @param data CodeCompanion.InlineArgs Data containing context information about the code block
|
||||
--- @param ns_id number unique namespace id for the extmarks
|
||||
local function create_extmarks(opts, data, ns_id)
|
||||
--- @type {bufnr: number, start_line: number, end_line: number}
|
||||
local context = data.context
|
||||
|
||||
-- Handle the case where start and end lines are the same (unique line)
|
||||
if context.start_line == context.end_line then
|
||||
set_line_extmark(context.bufnr, ns_id, context.start_line, opts, "unique_line_sign_text")
|
||||
return
|
||||
end
|
||||
|
||||
-- Set extmark for the first line with special options
|
||||
set_line_extmark(context.bufnr, ns_id, context.start_line, opts, "first_line_sign_text")
|
||||
|
||||
-- Set extmarks for the middle lines with standard options
|
||||
for i = context.start_line + 1, context.end_line - 1 do
|
||||
vim.api.nvim_buf_set_extmark(context.bufnr, ns_id, i - 1, 0, opts.extmark)
|
||||
end
|
||||
|
||||
-- Set extmark for the last line with special options
|
||||
if context.end_line > context.start_line then
|
||||
set_line_extmark(context.bufnr, ns_id, context.end_line, opts, "last_line_sign_text")
|
||||
end
|
||||
end
|
||||
|
||||
--- Creates autocmds for CodeCompanionRequest events
|
||||
--- @param opts CodeCompanion.InlineExtmark Configuration options passed from setup
|
||||
local function create_autocmds(opts)
|
||||
vim.api.nvim_create_autocmd({ "User" }, {
|
||||
pattern = { "CodeCompanionRequest*" },
|
||||
callback =
|
||||
--- @param args {buf: number, data : CodeCompanion.InlineArgs, match: string}
|
||||
function(args)
|
||||
local data = args.data or {}
|
||||
local context = data and data.context or {}
|
||||
if data and data.context then
|
||||
local ns_id = vim.api.nvim_create_namespace("CodeCompanionInline_" .. data.id)
|
||||
if args.match:find("StartedInline") then
|
||||
create_extmarks(opts, data, ns_id)
|
||||
elseif args.match:find("FinishedInline") then
|
||||
vim.api.nvim_buf_clear_namespace(context.bufnr, ns_id, 0, -1)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
--- @param opts? CodeCompanion.InlineExtmark Optional configuration to override defaults
|
||||
function M.setup(opts)
|
||||
create_autocmds(vim.tbl_deep_extend("force", default_opts, opts or {}))
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
local opts = { noremap = true, silent = false }
|
||||
|
||||
--- Set keybindings from a table of mappings.
|
||||
--- @param bindings table A list of keybinding mappings.
|
||||
|
||||
82
.config/nvim/lua/utils/ruff.toml
Normal file
82
.config/nvim/lua/utils/ruff.toml
Normal file
@@ -0,0 +1,82 @@
|
||||
exclude = [
|
||||
".bzr",
|
||||
".direnv",
|
||||
".eggs",
|
||||
".git",
|
||||
".git-rewrite",
|
||||
".hg",
|
||||
".ipynb_checkpoints",
|
||||
".mypy_cache",
|
||||
".nox",
|
||||
".pants.d",
|
||||
".pyenv",
|
||||
".pytest_cache",
|
||||
".pytype",
|
||||
".ruff_cache",
|
||||
".svn",
|
||||
".tox",
|
||||
".venv",
|
||||
".vscode",
|
||||
"__pypackages__",
|
||||
"_build",
|
||||
"buck-out",
|
||||
"build",
|
||||
"dist",
|
||||
"node_modules",
|
||||
"site-packages",
|
||||
"venv",
|
||||
"env"
|
||||
]
|
||||
|
||||
# Same as Black.
|
||||
line-length = 88
|
||||
indent-width = 4
|
||||
|
||||
# Assume Python 3.9
|
||||
target-version = "py39"
|
||||
|
||||
[lint]
|
||||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
||||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
||||
# McCabe complexity (`C901`) by default.
|
||||
select = ["D"]
|
||||
ignore = ["D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "D417"]
|
||||
|
||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||
fixable = ["ALL"]
|
||||
unfixable = []
|
||||
|
||||
# Allow unused variables when underscore-prefixed.
|
||||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||
|
||||
[lint.pydocstyle]
|
||||
convention = "numpy" # Accepts: "google", "numpy", or "pep257".
|
||||
|
||||
[format]
|
||||
# Like Black, use double quotes for strings.
|
||||
quote-style = "double"
|
||||
|
||||
# Like Black, indent with spaces, rather than tabs.
|
||||
indent-style = "spaces"
|
||||
|
||||
# Like Black, respect magic trailing commas.
|
||||
skip-magic-trailing-comma = false
|
||||
|
||||
# Like Black, automatically detect the appropriate line ending.
|
||||
line-ending = "auto"
|
||||
|
||||
# Enable auto-formatting of code examples in docstrings. Markdown,
|
||||
# reStructuredText code/literal blocks and doctests are all supported.
|
||||
#
|
||||
# This is currently disabled by default, but it is planned for this
|
||||
# to be opt-out in the future.
|
||||
docstring-code-format = true
|
||||
|
||||
# Set the line length limit used when formatting code snippets in
|
||||
# docstrings.
|
||||
#
|
||||
# This only has an effect when the `docstring-code-format` setting is
|
||||
# enabled.
|
||||
docstring-code-line-length = "dynamic"
|
||||
|
||||
respect-gitignore = true
|
||||
@@ -3,6 +3,30 @@ local telescopeConfig = require("telescope.config")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.find_and_paste_image()
|
||||
local telescope = require("telescope.builtin")
|
||||
local actions = require("telescope.actions")
|
||||
local action_state = require("telescope.actions.state")
|
||||
|
||||
telescope.find_files({
|
||||
attach_mappings = function(_, map)
|
||||
local function embed_image(prompt_bufnr)
|
||||
local entry = action_state.get_selected_entry()
|
||||
local filepath = entry[1]
|
||||
actions.close(prompt_bufnr)
|
||||
|
||||
local img_clip = require("img-clip")
|
||||
img_clip.paste_image(nil, filepath)
|
||||
end
|
||||
|
||||
map("i", "<CR>", embed_image)
|
||||
map("n", "<CR>", embed_image)
|
||||
|
||||
return true
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
-- Clone the default Telescope configuration
|
||||
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
|
||||
|
||||
Reference in New Issue
Block a user