Compare commits
23 Commits
b03e50f630
...
copilot-lu
| Author | SHA1 | Date | |
|---|---|---|---|
|
6bc0b1a0da
|
|||
|
f34ddbac36
|
|||
|
b3495ef161
|
|||
|
e7aaee0dd6
|
|||
|
513f2e3e20
|
|||
|
ad93476190
|
|||
|
620dd92101
|
|||
|
0904b788b1
|
|||
|
cdf15743c3
|
|||
|
29eb480ac0
|
|||
|
3148fa47c2
|
|||
|
67b668bf60
|
|||
|
e3394bb65c
|
|||
|
4b1128f820
|
|||
|
a6285798bf
|
|||
|
c3ae8bbe1e
|
|||
|
6dfaad2127
|
|||
|
300cd3b567
|
|||
|
d076dcf093
|
|||
|
5149c12b9a
|
|||
|
1917c81067
|
|||
|
7b7df6a343
|
|||
|
f36177b126
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
7
after/lsp/docker_language_server.lua
Normal file
7
after/lsp/docker_language_server.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
settings = {
|
||||
initializationOptions = {
|
||||
telemetry = "off",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -13,6 +13,9 @@ vim.o.mouse = ""
|
||||
vim.o.mousescroll = "ver:0,hor:0"
|
||||
vim.o.writebackup = false
|
||||
vim.o.undofile = true
|
||||
vim.o.updatetime = 250
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 300
|
||||
|
||||
-- ui
|
||||
vim.o.breakindent = true
|
||||
@@ -32,6 +35,32 @@ vim.o.expandtab = true
|
||||
vim.o.ignorecase = 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"
|
||||
|
||||
-- default plus added dash
|
||||
|
||||
@@ -5,6 +5,7 @@ MiniDeps.now(function()
|
||||
vim.g.gruvbox_material_background = "light"
|
||||
vim.g.gruvbox_material_better_performance = 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_enable_bold = 1
|
||||
vim.g.gruvbox_material_enable_italic = 1
|
||||
|
||||
79
lua/plugins/copilot.lua
Normal file
79
lua/plugins/copilot.lua
Normal 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)
|
||||
@@ -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)
|
||||
@@ -9,4 +9,12 @@ MiniDeps.later(function()
|
||||
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)
|
||||
|
||||
@@ -10,6 +10,9 @@ MiniDeps.later(function()
|
||||
"ruff",
|
||||
"stylua",
|
||||
"lua_ls",
|
||||
"nixd",
|
||||
"nil_ls",
|
||||
"docker_language_server",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
@@ -55,6 +58,36 @@ MiniDeps.later(function()
|
||||
"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
|
||||
if client and client.server_capabilities.inlayHintProvider then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
|
||||
12
lua/plugins/mini_cursorword.lua
Normal file
12
lua/plugins/mini_cursorword.lua
Normal 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)
|
||||
@@ -1,10 +1,24 @@
|
||||
MiniDeps.later(
|
||||
function()
|
||||
require("mini.indentscope").setup({
|
||||
draw = {
|
||||
delay = 0,
|
||||
animation = require("mini.indentscope").gen_animation.none(),
|
||||
},
|
||||
})
|
||||
MiniDeps.later(function()
|
||||
require("mini.indentscope").setup({
|
||||
draw = {
|
||||
delay = 0,
|
||||
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
|
||||
)
|
||||
|
||||
vim.api.nvim_create_autocmd("TermOpen", { callback = term_disable })
|
||||
vim.api.nvim_create_autocmd("Filetype", { callback = ft_disable })
|
||||
end)
|
||||
|
||||
@@ -1,7 +1,36 @@
|
||||
MiniDeps.now(
|
||||
function()
|
||||
require("mini.starter").setup({
|
||||
query_updaters = "abcdefghijklmnopqrstuvwxyz0123456789_.",
|
||||
})
|
||||
end
|
||||
)
|
||||
local function default_header()
|
||||
local hour = tonumber(vim.fn.strftime("%H"))
|
||||
local part_id = math.floor((hour + 4) / 8) + 1
|
||||
local day_part = ({ "evening", "morning", "afternoon", "evening" })[part_id]
|
||||
local username = vim.loop.os_get_passwd()["username"] or "USERNAME"
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
return {
|
||||
["fzf-lua"] = "c0c0926eee09f2e7868e5b72cb66decc0cb13aca",
|
||||
["git-blame.nvim"] = "9874ec1ec8bc53beb33b7cd82c092b85271a578b",
|
||||
["copilot.lua"] = "3123983d00ae6859f8bc987d14ebb524bb41b618",
|
||||
["fzf-lua"] = "db3ccffe79480543d8e0f7b0cac0d9b220f9486e",
|
||||
["gitlinker.nvim"] = "cc59f732f3d043b626c8702cb725c82e54d35c25",
|
||||
["gitsigns.nvim"] = "1ee5c1fd068c81f9dd06483e639c2aa4587dc197",
|
||||
["gruvbox-material"] = "834dbf21836862300ced7444db4262b796330ab7",
|
||||
["guess-indent.nvim"] = "84a4987ff36798c2fc1169cbaff67960aed9776f",
|
||||
["mini.nvim"] = "fbb6ad02871d296fc7d3ebd453e1be89b1210f68",
|
||||
["nvim-lspconfig"] = "e688b486fe9291f151eae7e5c0b5a5c4ef980847",
|
||||
["nvim-treesitter"] = "3ab4f2d2d20be55874e2eb575145c6928d7d7d0e",
|
||||
["mini.nvim"] = "5e1dd6e3d5f758eccf6c51461559da785dba688c",
|
||||
["nvim-lspconfig"] = "ac98db2f9f06a56498ec890a96928774eae412c3",
|
||||
["nvim-treesitter"] = "0606c7a9dcaa5c5beee0b0f09043e9fdd1ba0a68",
|
||||
["oil.nvim"] = "919e155fdf38e9148cdb5304faaaf53c20d703ea",
|
||||
["plenary.nvim"] = "b9fd5226c2f76c951fc8ed5923d85e4de065e509",
|
||||
["rainbow-delimiters.nvim"] = "3277ad5f96eb03c9d618c88e24f683e4364e578c",
|
||||
["todo-comments.nvim"] = "304a8d204ee787d2544d8bc23cd38d2f929e7cc5"
|
||||
["todo-comments.nvim"] = "19d461ddd543e938eb22505fb03fa878800270b6"
|
||||
}
|
||||
|
||||
44
plugin/geterm.lua
Normal file
44
plugin/geterm.lua
Normal 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))
|
||||
Reference in New Issue
Block a user