This commit is contained in:
Dmitri 2025-09-22 22:45:34 +02:00
parent 28598c5e1d
commit 7e84c2f591
Signed by: kanopo
GPG Key ID: 759ADD40E3132AC7
10 changed files with 233 additions and 203 deletions

View File

@ -1,8 +1,7 @@
root = true root = true
# Unix-style newlines with a newline ending every file [*.lua]
[*]
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
indent_style = space indent_style = space
indent_size = 4 indent_size = 2

View File

View File

@ -1,17 +1,3 @@
-- vim.cmd.colorscheme("gruvbox")
-- vim.lsp.enable('lua_ls')
--
-- require("mason").setup()
-- require("mason-lspconfig").setup {
-- ensure_installed = { "lua_ls" }
-- }
-- local ls = require("luasnip")
-- ls.setup({
-- enable_autosnippets = true
-- })
require("kanopo.options") require("kanopo.options")
require("kanopo.autocmds") require("kanopo.autocmds")
require("kanopo.plugins") require("kanopo.plugins")

View File

@ -33,3 +33,21 @@ vim.api.nvim_create_autocmd("BufReadPost", {
end end
end, end,
}) })
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('my.lsp', {}),
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
if not client:supports_method('textDocument/willSaveWaitUntil')
and client:supports_method('textDocument/formatting') then
vim.api.nvim_create_autocmd('BufWritePre', {
group = vim.api.nvim_create_augroup('my.lsp', { clear = false }),
buffer = args.buf,
callback = function()
vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 })
end,
})
end
end,
})

View File

@ -0,0 +1,28 @@
vim.pack.add({
{ src = "https://github.com/saghen/blink.cmp", version = "1.*" },
{ src = "https://github.com/rafamadriz/friendly-snippets" }
})
-- Load packs on startup (guard for nightlies without load)
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
-- Preload neogit module if available (optional)
pcall(function()
require("blink").setup({
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept):
-- 'super-tab' for mappings similar to vscode (tab to accept)
-- 'enter' for enter to accept
-- 'none' for no mappings
-- All presets have the following mappings:
-- C-space: Open menu or open docs if already open
-- C-n/C-p or Up/Down: Select next/previous item
-- C-e: Hide menu
-- C-k: Toggle signature help (if signature.enabled = true)
keymap = { preset = 'default' },
})
end)
end,
})

View File

@ -1,37 +1,37 @@
-- Declare plugins -- Declare plugins
vim.pack.add({ vim.pack.add({
{ src = "https://github.com/NeogitOrg/neogit" }, { src = "https://github.com/NeogitOrg/neogit" },
{ src = "https://github.com/lewis6991/gitsigns.nvim" }, { src = "https://github.com/lewis6991/gitsigns.nvim" },
}) })
-- Load packs on startup (guard for nightlies without load) -- Load packs on startup (guard for nightlies without load)
vim.api.nvim_create_autocmd("VimEnter", { vim.api.nvim_create_autocmd("VimEnter", {
once = true, once = true,
callback = function() callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end if vim.pack and vim.pack.load then pcall(vim.pack.load) end
-- Configure gitsigns (safe pcall) -- Configure gitsigns (safe pcall)
pcall(function() pcall(function()
require("gitsigns").setup() require("gitsigns").setup()
end) end)
-- Preload neogit module if available (optional) -- Preload neogit module if available (optional)
pcall(function() pcall(function()
require("neogit") require("neogit")
end) end)
end, end,
}) })
-- Keymap: open Neogit (on-demand load if needed) -- Keymap: open Neogit (on-demand load if needed)
vim.keymap.set("n", "<leader>gg", function() vim.keymap.set("n", "<leader>gg", function()
local ok, neogit = pcall(require, "neogit") local ok, neogit = pcall(require, "neogit")
if not ok then if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, neogit = pcall(require, "neogit") ok, neogit = pcall(require, "neogit")
end end
if ok then if ok then
neogit.open({}) neogit.open({})
else else
vim.notify("neogit not available yet", vim.log.levels.WARN) vim.notify("neogit not available yet", vim.log.levels.WARN)
end end
end, { desc = "Open Neogit" }) end, { desc = "Open Neogit" })

View File

@ -1,8 +1,9 @@
-- require("kanopo.plugins.lazydev") require("kanopo.plugins.lazydev")
require("kanopo.plugins.oil") require("kanopo.plugins.oil")
require("kanopo.plugins.theme") require("kanopo.plugins.theme")
require("kanopo.plugins.treesitter") require("kanopo.plugins.treesitter")
require("kanopo.plugins.telescope") require("kanopo.plugins.telescope")
require("kanopo.plugins.cmp")
require("kanopo.plugins.lsp") require("kanopo.plugins.lsp")
require("kanopo.plugins.which-key") require("kanopo.plugins.which-key")
require("kanopo.plugins.git") require("kanopo.plugins.git")

View File

@ -1,190 +1,192 @@
vim.pack.add({ vim.pack.add({
{ src = "https://github.com/neovim/nvim-lspconfig" }, { src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/mason-org/mason.nvim" }, { src = "https://github.com/mason-org/mason.nvim" },
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" }, { src = "https://github.com/mason-org/mason-lspconfig.nvim" },
{ src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" }, -- optional for tools later { src = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" }, -- optional for tools later
{ src = "https://github.com/L3MON4D3/LuaSnip" },
{ src = "https://github.com/rafamadriz/friendly-snippets" }, { src = "https://github.com/saghen/blink.cmp", version = "1.*" },
-- { src = "https://github.com/L3MON4D3/LuaSnip" },
-- { src = "https://github.com/rafamadriz/friendly-snippets" },
}) })
-- Load packs early (guard API) -- Load packs early (guard API)
vim.api.nvim_create_autocmd("VimEnter", { vim.api.nvim_create_autocmd("VimEnter", {
once = true, once = true,
callback = function() callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end if vim.pack and vim.pack.load then pcall(vim.pack.load) end
end, end,
}) })
-- Servers you want -- Servers you want
local lsp_servers = { local lsp_servers = {
"lua_ls", "lua_ls",
"ts_ls", "ts_ls",
"texlab", "texlab",
"marksman", "marksman",
"docker_compose_language_service", "docker_compose_language_service",
"dockerls", "dockerls",
"tailwindcss", "tailwindcss",
"cssls", "cssls",
"clangd", "clangd",
"rust_analyzer", "rust_analyzer",
"gopls", "gopls",
} }
-- Optional: tools you might install later (kept, but not used for formatting here) -- Optional: tools you might install later (kept, but not used for formatting here)
local tools = { local tools = {
"luacheck", "luacheck",
"latexindent", "latexindent",
"prettierd", "prettierd",
} }
-- Mason + mason-lspconfig -- Mason + mason-lspconfig
do do
local ok, mason = pcall(require, "mason") local ok, mason = pcall(require, "mason")
if ok then mason.setup() end if ok then mason.setup() end
local ok_mlsp, mlsp = pcall(require, "mason-lspconfig") local ok_mlsp, mlsp = pcall(require, "mason-lspconfig")
if ok_mlsp then if ok_mlsp then
mlsp.setup({ mlsp.setup({
ensure_installed = lsp_servers, ensure_installed = lsp_servers,
automatic_enable = true, -- v2 automatic_enable = true, -- v2
}) })
end end
-- If you want mason-tool-installer to fetch tools only (no config in this file): -- If you want mason-tool-installer to fetch tools only (no config in this file):
local ok_mti, mti = pcall(require, "mason-tool-installer") local ok_mti, mti = pcall(require, "mason-tool-installer")
if ok_mti then if ok_mti then
mti.setup({ mti.setup({
ensure_installed = tools, -- harmless to keep; you can remove if you prefer ensure_installed = tools, -- harmless to keep; you can remove if you prefer
automatic_installation = true, automatic_installation = true,
}) })
end end
local ok_ls, ls = pcall(require, "luasnip")
if ok_ls then
ls.config.set_config({
history = true,
enable_autosnippets = false,
})
-- Load VSCode-style snippets from friendly-snippets (and any other VSCode snippet dirs on rtp)
-- pcall(function()
-- require("luasnip.loaders.from_vscode").lazy_load()
-- end)
-- Your Tab/Shift-Tab mappings...
end
end end
-- Shared on_attach: native omni + Telescope pickers -- Shared on_attach: native omni + Telescope pickers
local function on_attach(_, bufnr) local function on_attach(_, bufnr)
vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr }) vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr })
vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = bufnr }) vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = bufnr })
local function map(mode, lhs, rhs, desc) local function map(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc }) vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc })
end
-- Telescope-powered LSP navigation (loads telescope.builtin on demand)
local function tb(fn)
return function()
local ok, builtin = pcall(require, "telescope.builtin")
if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, builtin = pcall(require, "telescope.builtin")
end
if ok and builtin[fn] then
builtin[fn]()
else
vim.notify("Telescope not available", vim.log.levels.WARN)
end
end end
end
local group = vim.api.nvim_create_augroup("LspFormatOnSave_" .. bufnr, { clear = true }) map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)")
vim.api.nvim_create_autocmd("BufWritePre", { map("n", "gr", tb("lsp_references"), "Goto References (Telescope)")
group = group, map("n", "gI", tb("lsp_implementations"), "Goto Implementations (Telescope)")
buffer = bufnr, map("n", "gt", tb("lsp_type_definitions"), "Goto Type Definitions (Telescope)")
callback = function()
-- Prefer synchronous formatting with timeout to avoid blocking too long
if vim.lsp.buf.format then
vim.lsp.buf.format({
async = false,
timeout_ms = 1500,
})
end
end,
desc = "LSP format before save",
})
-- Telescope-powered LSP navigation (loads telescope.builtin on demand) -- LSP basics
local function tb(fn) map("n", "K", vim.lsp.buf.hover, "Hover")
return function() map("n", "<leader>rn", vim.lsp.buf.rename, "Rename")
local ok, builtin = pcall(require, "telescope.builtin") map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "Code Action")
if not ok then map("n", "[d", vim.diagnostic.goto_prev, "Prev Diagnostic")
if vim.pack and vim.pack.load then pcall(vim.pack.load) end map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic")
ok, builtin = pcall(require, "telescope.builtin") map("n", "<leader>e", vim.diagnostic.open_float, "Line Diagnostics")
end
if ok and builtin[fn] then
builtin[fn]()
else
vim.notify("Telescope not available", vim.log.levels.WARN)
end
end
end
map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)") pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr })
map("n", "gr", tb("lsp_references"), "Goto References (Telescope)")
map("n", "gI", tb("lsp_implementations"), "Goto Implementations (Telescope)")
map("n", "gt", tb("lsp_type_definitions"), "Goto Type Definitions (Telescope)")
-- LSP basics
map("n", "K", vim.lsp.buf.hover, "Hover")
map("n", "<leader>rn", vim.lsp.buf.rename, "Rename")
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "Code Action")
map("n", "[d", vim.diagnostic.goto_prev, "Prev Diagnostic")
map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic")
map("n", "<leader>e", vim.diagnostic.open_float, "Line Diagnostics")
pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr })
end end
-- Global LSP defaults -- Global LSP defaults
vim.lsp.config("*", { vim.lsp.config("*", {
on_attach = on_attach, on_attach = on_attach,
capabilities = (function() capabilities = require('blink.cmp').get_lsp_capabilities()
local caps = vim.lsp.protocol.make_client_capabilities() -- capabilities = (function()
caps.textDocument = caps.textDocument or {} -- local caps = vim.lsp.protocol.make_client_capabilities()
caps.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } -- caps.textDocument = caps.textDocument or {}
return caps -- caps.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
end)(), -- return caps
-- end)(),
}) })
-- Server-specific tweaks -- -- Server-specific tweaks
vim.lsp.config("lua_ls", { -- vim.lsp.config("lua_ls", {
settings = { -- settings = {
Lua = { -- Lua = {
diagnostics = { globals = { "vim", "require" } }, -- diagnostics = { globals = { "vim", "require" } },
completion = { callSnippet = "Replace" }, -- completion = { callSnippet = "Replace" },
workspace = { checkThirdParty = false }, -- workspace = { checkThirdParty = false },
}, -- },
}, -- },
}) -- })
-- Enable servers (Neovim 0.11+) -- Enable servers (Neovim 0.11+)
vim.lsp.enable(lsp_servers) vim.lsp.enable(lsp_servers)
-- Trigger omni (like cmp.complete) -- -- Trigger omni (like cmp.complete)
vim.keymap.set("i", "<C-Space>", function() -- vim.keymap.set("i", "<C-Space>", function()
if vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" then -- if vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" then
return vim.api.nvim_replace_termcodes("<C-x><C-o>", true, true, true) -- return vim.api.nvim_replace_termcodes("<C-x><C-o>", true, true, true)
end -- end
return "" -- return ""
end, { expr = true, silent = true, desc = "Trigger omni-completion" }) -- end, { expr = true, silent = true, desc = "Trigger omni-completion" })
--
-- Navigate popup menu -- -- Navigate popup menu
vim.keymap.set("i", "<C-j>", "<C-n>", { silent = true, desc = "Omni next item" }) -- vim.keymap.set("i", "<C-j>", "<C-n>", { silent = true, desc = "Omni next item" })
vim.keymap.set("i", "<C-k>", "<C-p>", { silent = true, desc = "Omni prev item" }) -- vim.keymap.set("i", "<C-k>", "<C-p>", { silent = true, desc = "Omni prev item" })
--
-- Enter to confirm when pum is visible, otherwise newline -- -- Enter to confirm when pum is visible, otherwise newline
vim.keymap.set("i", "<CR>", function() -- vim.keymap.set("i", "<CR>", function()
if vim.fn.pumvisible() == 1 then -- if vim.fn.pumvisible() == 1 then
-- Confirm current selection; if none selected, accept first -- -- Confirm current selection; if none selected, accept first
return vim.api.nvim_replace_termcodes("<C-y>", true, true, true) -- return vim.api.nvim_replace_termcodes("<C-y>", true, true, true)
end -- end
return vim.api.nvim_replace_termcodes("<CR>", true, true, true) -- return vim.api.nvim_replace_termcodes("<CR>", true, true, true)
end, { expr = true, silent = true, desc = "Confirm completion or newline" }) -- end, { expr = true, silent = true, desc = "Confirm completion or newline" })
--
-- Requires your existing LuaSnip setup and mappings -- -- Requires your existing LuaSnip setup and mappings
local ok_ls, ls = pcall(require, "luasnip") -- local ok_ls, ls = pcall(require, "luasnip")
if ok_ls then -- if ok_ls then
-- Tab: if menu visible, next item; else snippet expand/jump; else literal Tab -- -- Tab: if menu visible, next item; else snippet expand/jump; else literal Tab
vim.keymap.set({ "i", "s" }, "<Tab>", function() -- vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.fn.pumvisible() == 1 then -- if vim.fn.pumvisible() == 1 then
return vim.api.nvim_replace_termcodes("<C-n>", true, true, true) -- return vim.api.nvim_replace_termcodes("<C-n>", true, true, true)
elseif ls.expand_or_jumpable() then -- elseif ls.expand_or_jumpable() then
return "<Plug>luasnip-expand-or-jump" -- return "<Plug>luasnip-expand-or-jump"
else -- else
return "<Tab>" -- return "<Tab>"
end -- end
end, { expr = true, silent = true, desc = "Next item / Snippet jump / Tab" }) -- end, { expr = true, silent = true, desc = "Next item / Snippet jump / Tab" })
--
-- Shift-Tab: if menu visible, prev item; else snippet jump back; else literal -- -- Shift-Tab: if menu visible, prev item; else snippet jump back; else literal
vim.keymap.set({ "i", "s" }, "<S-Tab>", function() -- vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if vim.fn.pumvisible() == 1 then -- if vim.fn.pumvisible() == 1 then
return vim.api.nvim_replace_termcodes("<C-p>", true, true, true) -- return vim.api.nvim_replace_termcodes("<C-p>", true, true, true)
elseif ls.jumpable(-1) then -- elseif ls.jumpable(-1) then
return "<Plug>luasnip-jump-prev" -- return "<Plug>luasnip-jump-prev"
else -- else
return "<S-Tab>" -- return "<S-Tab>"
end -- end
end, { expr = true, silent = true, desc = "Prev item / Snippet back / Shift-Tab" }) -- end, { expr = true, silent = true, desc = "Prev item / Snippet back / Shift-Tab" })
end -- end

View File

@ -1,9 +1,9 @@
-- Ensure packs are added -- Ensure packs are added
vim.pack.add({ vim.pack.add({
{ src = "https://github.com/nvim-lua/plenary.nvim", version = "master" }, { src = "https://github.com/nvim-lua/plenary.nvim", version = "master" },
{ src = "https://github.com/nvim-telescope/telescope.nvim", version = "master" }, { src = "https://github.com/nvim-telescope/telescope.nvim", version = "master" },
-- Optional native sorter (requires a C toolchain) -- Optional native sorter (requires a C toolchain)
{ src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim", version = "main", build = "make" }, { src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim", version = "main", build = "make" },
}) })
-- Helper: find fzf-native root and build/lib path if installed -- Helper: find fzf-native root and build/lib path if installed
@ -42,10 +42,12 @@ local function telescope_setup()
telescope.setup({ telescope.setup({
pickers = { pickers = {
find_files = { find_files = {
theme = "ivy",
hidden = true, hidden = true,
prompt_prefix = "🔍 ", prompt_prefix = "🔍 ",
}, },
live_grep = { live_grep = {
theme = "ivy",
hidden = true, hidden = true,
prompt_prefix = "🔍 ", prompt_prefix = "🔍 ",
}, },

View File

@ -1,6 +0,0 @@
const ciao = () => {
console.log("ciao")
}
ciao()