Compare commits

23 Commits

Author SHA1 Message Date
6bc0b1a0da wip: copilot.lua 2025-10-19 20:51:23 +02:00
f34ddbac36 chore: update to client:supports_method 2025-10-18 03:31:43 +02:00
b3495ef161 feat: close pumenu on copilot-suggest 2025-10-18 03:27:46 +02:00
e7aaee0dd6 feat: add nvim-mini/mini.cursorword 2025-10-18 02:57:20 +02:00
513f2e3e20 feat: use vim.tbl_contains api where possible 2025-10-18 02:56:49 +02:00
ad93476190 chore: add year to LICENSE 2025-10-18 02:44:59 +02:00
620dd92101 feat: add DepsClean to mini.starter 2025-10-18 02:43:51 +02:00
0904b788b1 feat: replace f-person/git-blame.nvim with lewis6991/gitsigns.nvim 2025-10-18 02:42:56 +02:00
cdf15743c3 feat: disable mini.indentscope for fzf and term 2025-10-17 16:52:38 +02:00
29eb480ac0 feat: enable vim.g.gruvbox_material_diagnostic_text_highlight 2025-10-17 16:51:24 +02:00
3148fa47c2 feat: add semantic highlighting via lsp.textDocument_documentHighlight 2025-10-16 14:36:13 +02:00
67b668bf60 feat: enable virtual_text for diagnostic and add swap_diagnostic keymap 2025-10-14 00:12:05 +02:00
e3394bb65c chore: bump plugins 2025-10-13 12:41:19 +02:00
4b1128f820 fix: setup ocs52 copy for * register 2025-10-13 00:12:44 +02:00
a6285798bf feat: add debug section to mini.starter 2025-10-11 22:29:04 +02:00
c3ae8bbe1e feat: add custom mini.starter sections 2025-10-11 21:26:21 +02:00
6dfaad2127 chore: bump plugins 2025-10-11 21:26:03 +02:00
300cd3b567 feat: add github/copilot.vim 2025-10-11 20:39:27 +02:00
d076dcf093 fix: create new terminal if old isn't valid anymore 2025-10-11 20:35:04 +02:00
5149c12b9a feat: add docker_language_server 2025-10-11 18:55:13 +02:00
1917c81067 feat: add nil_ls and nixd language servers 2025-10-11 18:54:34 +02:00
7b7df6a343 feat: add simple script for managing terminals 2025-10-11 18:53:22 +02:00
f36177b126 feat: add system clipboard copy via osc52 codes 2025-10-11 18:51:17 +02:00
13 changed files with 279 additions and 34 deletions

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) Matej Janežič Copyright (c) 2025 Matej Janežič
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -0,0 +1,7 @@
return {
settings = {
initializationOptions = {
telemetry = "off",
},
},
}

View File

@@ -13,6 +13,9 @@ vim.o.mouse = ""
vim.o.mousescroll = "ver:0,hor:0" vim.o.mousescroll = "ver:0,hor:0"
vim.o.writebackup = false vim.o.writebackup = false
vim.o.undofile = true vim.o.undofile = true
vim.o.updatetime = 250
vim.o.timeout = true
vim.o.timeoutlen = 300
-- ui -- ui
vim.o.breakindent = true vim.o.breakindent = true
@@ -32,6 +35,32 @@ vim.o.expandtab = true
vim.o.ignorecase = true vim.o.ignorecase = true
vim.o.smartcase = true vim.o.smartcase = true
-- diagnostic show virtual text
vim.diagnostic.config({ virtual_text = true })
local function swap_diagnostic()
local virtext = vim.diagnostic.config().virtual_text
local virlines = vim.diagnostic.config().virtual_lines
vim.diagnostic.config({ virtual_text = not virtext, virtual_lines = not virlines })
end
vim.keymap.set("n", "<leader>dt", swap_diagnostic)
-- osc52 escape codes copy
local function ocs52_paste_fail()
vim.notify("can't paste via osc52", vim.log.levels.WARN)
return {}
end
vim.g.clipboard = {
name = "osc52-writeonly",
copy = {
["+"] = require("vim.ui.clipboard.osc52").copy("+"),
["*"] = require("vim.ui.clipboard.osc52").copy("*"),
},
paste = {
["+"] = ocs52_paste_fail,
["*"] = ocs52_paste_fail,
},
}
vim.o.completeopt = "menuone,noselect,fuzzy,nosort" vim.o.completeopt = "menuone,noselect,fuzzy,nosort"
-- default plus added dash -- default plus added dash

View File

@@ -5,6 +5,7 @@ MiniDeps.now(function()
vim.g.gruvbox_material_background = "light" vim.g.gruvbox_material_background = "light"
vim.g.gruvbox_material_better_performance = 1 vim.g.gruvbox_material_better_performance = 1
vim.g.gruvbox_material_diagnostic_line_highlight = 1 vim.g.gruvbox_material_diagnostic_line_highlight = 1
vim.g.gruvbox_material_diagnostic_text_highlight = 1
vim.g.gruvbox_material_diagnostic_virtual_text = "colored" vim.g.gruvbox_material_diagnostic_virtual_text = "colored"
vim.g.gruvbox_material_enable_bold = 1 vim.g.gruvbox_material_enable_bold = 1
vim.g.gruvbox_material_enable_italic = 1 vim.g.gruvbox_material_enable_italic = 1

79
lua/plugins/copilot.lua Normal file
View File

@@ -0,0 +1,79 @@
MiniDeps.later(function()
MiniDeps.add("zbirenbaum/copilot.lua")
-- TODO:(@janezicmatej) setup lsp nes
-- MiniDeps.add("copilotlsp-nvim/copilot-lsp")
local function no_attach_for_env()
if string.match(vim.fs.basename(vim.api.nvim_buf_get_name(0)), "^%.env.*") then
return false
end
return true
end
local opts = {
panel = {
keymap = {
jump_prev = false,
jump_next = false,
accept = false,
refresh = false,
open = false,
},
},
suggestion = {
-- auto_trigger = true,
keymap = {
accept = false,
accept_word = false,
accept_line = false,
next = false,
prev = false,
dismiss = false,
},
},
filetypes = {
-- disable all and only allow specific filetyps
["*"] = false,
--
c = true,
cpp = true,
dockerfile = true,
go = true,
javascript = true,
lua = true,
nix = true,
python = true,
rust = true,
sh = no_attach_for_env,
bash = no_attach_for_env,
typescript = true,
},
}
require("copilot").setup(opts)
local suggestion = require("copilot.suggestion")
local function accept_if_visible()
vim.notify("is visible " .. (suggestion.is_visible() or "nil"))
if suggestion.is_visible() ~= nil then
suggestion.accept()
else
return "<Tab>"
end
end
local function close_pum_if_open(func)
return function()
if vim.fn.pumvisible() == 1 then vim.fn.complete(vim.fn.col("."), {}) end
return func()
end
end
-- stylua: ignore start
vim.keymap.set({ "i" }, "<Tab>", accept_if_visible, { desc = "copilot: accept suggestion", expr = true })
vim.keymap.set({ "n", "i" }, "<M-j>", suggestion.accept_line, { desc = "copilot: accept line" })
vim.keymap.set({ "n", "i" }, "<M-l>", close_pum_if_open(suggestion.next), { desc = "copilot: next suggestion" })
vim.keymap.set({ "n", "i" }, "<M-h>", close_pum_if_open(suggestion.prev), { desc = "copilot: previous suggestion" })
-- stylua: ignore start
end)

View File

@@ -1,11 +0,0 @@
MiniDeps.later(function()
MiniDeps.add("f-person/git-blame.nvim")
require("gitblame").setup({
enabled = false,
message_template = " <sha>: <author> <date> <summary>",
date_format = "%Y-%m-%d",
})
vim.keymap.set("n", "<leader>gt", ":GitBlameToggle<CR>")
vim.keymap.set("n", "<leader>gs", ":GitBlameCopySHA<CR>")
end)

View File

@@ -9,4 +9,12 @@ MiniDeps.later(function()
changedelete = { text = "~" }, changedelete = { text = "~" },
}, },
}) })
-- blame
vim.keymap.set({"n", "v"}, "<leader>gb", ":Gitsigns blame<CR>")
vim.keymap.set({"n", "v"}, "<leader>gt", ":Gitsigns blame_line<CR>")
-- hunks
vim.keymap.set({"n", "v"}, "<leader>ga", ":Gitsigns stage_hunk<CR>")
vim.keymap.set({"n", "v"}, "<leader>gr", ":Gitsigns reset_hunk<CR>")
end) end)

View File

@@ -10,6 +10,9 @@ MiniDeps.later(function()
"ruff", "ruff",
"stylua", "stylua",
"lua_ls", "lua_ls",
"nixd",
"nil_ls",
"docker_language_server",
}) })
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
@@ -55,6 +58,36 @@ MiniDeps.later(function()
"format" "format"
) )
local tD_dH = vim.lsp.protocol.Methods.textDocument_documentHighlight
if client and client:supports_method(tD_dH) then
local ag = vim.api.nvim_create_augroup
local ac = vim.api.nvim_create_autocmd
local g = ag("custom-lsp-tD_dH-highlight", { clear = false })
ac({ "CursorHold", "CursorHoldI" }, {
buffer = bufnr,
group = g,
callback = vim.lsp.buf.document_highlight,
})
ac({ "CursorMoved", "CursorMovedI" }, {
buffer = bufnr,
group = g,
callback = vim.lsp.buf.clear_references,
})
ac("LspDetach", {
group = ag("custom-lsp-detach", { clear = true }),
callback = function(e)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({
group = "custom-lsp-tD_dH-highlight",
buffer = e.buf,
})
end,
})
end
-- inlay hints -- inlay hints
if client and client.server_capabilities.inlayHintProvider then if client and client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })

View File

@@ -0,0 +1,12 @@
MiniDeps.later(function()
require("mini.cursorword").setup()
local function disable(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
local tD_dH = vim.lsp.protocol.Methods.textDocument_documentHighlight
if client and not client:supports_method(tD_dH) then return end
vim.b[args.buf].minicursorword_disable = true
end
vim.api.nvim_create_autocmd("LspAttach", { callback = disable })
end)

View File

@@ -1,10 +1,24 @@
MiniDeps.later( MiniDeps.later(function()
function() require("mini.indentscope").setup({
require("mini.indentscope").setup({ draw = {
draw = { delay = 0,
delay = 0, animation = require("mini.indentscope").gen_animation.none(),
animation = require("mini.indentscope").gen_animation.none(), },
}, })
})
local disable = {
"fzf",
"fzflua_backdrop",
"qf",
}
local function term_disable(args) vim.b[args.buf].miniindentscope_disable = true end
local function ft_disable(args)
local ft = vim.bo[args.buf].filetype
if not vim.tbl_contains(disable, ft) then return end
vim.b[args.buf].miniindentscope_disable = true
end end
)
vim.api.nvim_create_autocmd("TermOpen", { callback = term_disable })
vim.api.nvim_create_autocmd("Filetype", { callback = ft_disable })
end)

View File

@@ -1,7 +1,36 @@
MiniDeps.now( local function default_header()
function() local hour = tonumber(vim.fn.strftime("%H"))
require("mini.starter").setup({ local part_id = math.floor((hour + 4) / 8) + 1
query_updaters = "abcdefghijklmnopqrstuvwxyz0123456789_.", local day_part = ({ "evening", "morning", "afternoon", "evening" })[part_id]
}) local username = vim.loop.os_get_passwd()["username"] or "USERNAME"
end
) return ("good %s, %s"):format(day_part, username)
end
local function reinstall_treesitter()
local ts = require("nvim-treesitter")
ts.install(ts.get_installed(), { force = true })
end
MiniDeps.now(function()
require("mini.starter").setup({
query_updaters = "abcdefghijklmnopqrstuvwxyz0123456789_.",
evaluate_single = true,
header = default_header,
footer = "",
items = {
--stylua: ignore start
-- builtins
{ name = "edit new buffer", action = "enew", section = "builtin actions" },
{ name = "quit neovim", action = "qall", section = "builtin actions" },
-- dependencies
{ name = "update dependencies", action = "DepsUpdate", section = "dependencies" },
{ name = "snap dependencies", action = "DepsSnapSave", section = "dependencies" },
{ name = "load dependencies", action = "DepsSnapLoad", section = "dependencies" },
{ name = "clean dependencies", action = "DepsClean", section = "dependencies" },
-- debug
{ name = "reinstall treesitter parsers", action = reinstall_treesitter, section = "debug" },
--stylua: ignore end
},
})
end)

View File

@@ -1,15 +1,15 @@
return { return {
["fzf-lua"] = "c0c0926eee09f2e7868e5b72cb66decc0cb13aca", ["copilot.lua"] = "3123983d00ae6859f8bc987d14ebb524bb41b618",
["git-blame.nvim"] = "9874ec1ec8bc53beb33b7cd82c092b85271a578b", ["fzf-lua"] = "db3ccffe79480543d8e0f7b0cac0d9b220f9486e",
["gitlinker.nvim"] = "cc59f732f3d043b626c8702cb725c82e54d35c25", ["gitlinker.nvim"] = "cc59f732f3d043b626c8702cb725c82e54d35c25",
["gitsigns.nvim"] = "1ee5c1fd068c81f9dd06483e639c2aa4587dc197", ["gitsigns.nvim"] = "1ee5c1fd068c81f9dd06483e639c2aa4587dc197",
["gruvbox-material"] = "834dbf21836862300ced7444db4262b796330ab7", ["gruvbox-material"] = "834dbf21836862300ced7444db4262b796330ab7",
["guess-indent.nvim"] = "84a4987ff36798c2fc1169cbaff67960aed9776f", ["guess-indent.nvim"] = "84a4987ff36798c2fc1169cbaff67960aed9776f",
["mini.nvim"] = "fbb6ad02871d296fc7d3ebd453e1be89b1210f68", ["mini.nvim"] = "5e1dd6e3d5f758eccf6c51461559da785dba688c",
["nvim-lspconfig"] = "e688b486fe9291f151eae7e5c0b5a5c4ef980847", ["nvim-lspconfig"] = "ac98db2f9f06a56498ec890a96928774eae412c3",
["nvim-treesitter"] = "3ab4f2d2d20be55874e2eb575145c6928d7d7d0e", ["nvim-treesitter"] = "0606c7a9dcaa5c5beee0b0f09043e9fdd1ba0a68",
["oil.nvim"] = "919e155fdf38e9148cdb5304faaaf53c20d703ea", ["oil.nvim"] = "919e155fdf38e9148cdb5304faaaf53c20d703ea",
["plenary.nvim"] = "b9fd5226c2f76c951fc8ed5923d85e4de065e509", ["plenary.nvim"] = "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
["rainbow-delimiters.nvim"] = "3277ad5f96eb03c9d618c88e24f683e4364e578c", ["rainbow-delimiters.nvim"] = "3277ad5f96eb03c9d618c88e24f683e4364e578c",
["todo-comments.nvim"] = "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" ["todo-comments.nvim"] = "19d461ddd543e938eb22505fb03fa878800270b6"
} }

44
plugin/geterm.lua Normal file
View File

@@ -0,0 +1,44 @@
---@class TermBuf
---@field buf_id integer
---@field term_id integer
---@type table<number, TermBuf>
local state = {}
---@param n integer
local function get_from_state(n)
local term_buf = state[n]
if term_buf ~= nil and vim.api.nvim_buf_is_valid(term_buf.buf_id) then
return term_buf
end
state[n] = nil
return nil
end
---@param n integer
local function get_or_create_term(n)
if get_from_state(n) ~= nil then
vim.api.nvim_win_set_buf(0, state[n].buf_id)
return
end
vim.cmd.terminal()
local buf_id = vim.api.nvim_get_current_buf()
local term_id = vim.b.terminal_job_id
vim.cmd.startinsert()
state[n] = { buf_id = buf_id, term_id = term_id }
end
---@param f function
local function count_fn(f)
local function wrap(...)
local count = vim.v.count
return f(count, arg)
end
return wrap
end
vim.keymap.set("n", "<leader>tn", count_fn(get_or_create_term))