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
# Unix-style newlines with a newline ending every file
[*]
[*.lua]
end_of_line = lf
insert_final_newline = true
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.autocmds")
require("kanopo.plugins")

View File

@ -33,3 +33,21 @@ vim.api.nvim_create_autocmd("BufReadPost", {
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
vim.pack.add({
{ src = "https://github.com/NeogitOrg/neogit" },
{ src = "https://github.com/lewis6991/gitsigns.nvim" },
{ src = "https://github.com/NeogitOrg/neogit" },
{ src = "https://github.com/lewis6991/gitsigns.nvim" },
})
-- 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
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
-- Configure gitsigns (safe pcall)
pcall(function()
require("gitsigns").setup()
end)
-- Configure gitsigns (safe pcall)
pcall(function()
require("gitsigns").setup()
end)
-- Preload neogit module if available (optional)
pcall(function()
require("neogit")
end)
end,
-- Preload neogit module if available (optional)
pcall(function()
require("neogit")
end)
end,
})
-- Keymap: open Neogit (on-demand load if needed)
vim.keymap.set("n", "<leader>gg", function()
local ok, neogit = pcall(require, "neogit")
if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, neogit = pcall(require, "neogit")
end
if ok then
neogit.open({})
else
vim.notify("neogit not available yet", vim.log.levels.WARN)
end
local ok, neogit = pcall(require, "neogit")
if not ok then
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
ok, neogit = pcall(require, "neogit")
end
if ok then
neogit.open({})
else
vim.notify("neogit not available yet", vim.log.levels.WARN)
end
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.theme")
require("kanopo.plugins.treesitter")
require("kanopo.plugins.telescope")
require("kanopo.plugins.cmp")
require("kanopo.plugins.lsp")
require("kanopo.plugins.which-key")
require("kanopo.plugins.git")

View File

@ -1,190 +1,192 @@
vim.pack.add({
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/mason-org/mason.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/L3MON4D3/LuaSnip" },
{ src = "https://github.com/rafamadriz/friendly-snippets" },
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/mason-org/mason.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/saghen/blink.cmp", version = "1.*" },
-- { src = "https://github.com/L3MON4D3/LuaSnip" },
-- { src = "https://github.com/rafamadriz/friendly-snippets" },
})
-- Load packs early (guard API)
vim.api.nvim_create_autocmd("VimEnter", {
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
end,
once = true,
callback = function()
if vim.pack and vim.pack.load then pcall(vim.pack.load) end
end,
})
-- Servers you want
local lsp_servers = {
"lua_ls",
"ts_ls",
"texlab",
"marksman",
"docker_compose_language_service",
"dockerls",
"tailwindcss",
"cssls",
"clangd",
"rust_analyzer",
"gopls",
"lua_ls",
"ts_ls",
"texlab",
"marksman",
"docker_compose_language_service",
"dockerls",
"tailwindcss",
"cssls",
"clangd",
"rust_analyzer",
"gopls",
}
-- Optional: tools you might install later (kept, but not used for formatting here)
local tools = {
"luacheck",
"latexindent",
"prettierd",
"luacheck",
"latexindent",
"prettierd",
}
-- Mason + mason-lspconfig
do
local ok, mason = pcall(require, "mason")
if ok then mason.setup() end
local ok, mason = pcall(require, "mason")
if ok then mason.setup() end
local ok_mlsp, mlsp = pcall(require, "mason-lspconfig")
if ok_mlsp then
mlsp.setup({
ensure_installed = lsp_servers,
automatic_enable = true, -- v2
})
end
local ok_mlsp, mlsp = pcall(require, "mason-lspconfig")
if ok_mlsp then
mlsp.setup({
ensure_installed = lsp_servers,
automatic_enable = true, -- v2
})
end
-- If you want mason-tool-installer to fetch tools only (no config in this file):
local ok_mti, mti = pcall(require, "mason-tool-installer")
if ok_mti then
mti.setup({
ensure_installed = tools, -- harmless to keep; you can remove if you prefer
automatic_installation = true,
})
end
-- If you want mason-tool-installer to fetch tools only (no config in this file):
local ok_mti, mti = pcall(require, "mason-tool-installer")
if ok_mti then
mti.setup({
ensure_installed = tools, -- harmless to keep; you can remove if you prefer
automatic_installation = true,
})
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
-- Shared on_attach: native omni + Telescope pickers
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("tagfunc", "v:lua.vim.lsp.tagfunc", { 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 })
local function map(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc })
local function map(mode, lhs, rhs, 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
local group = vim.api.nvim_create_augroup("LspFormatOnSave_" .. bufnr, { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = group,
buffer = bufnr,
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",
})
map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)")
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)")
-- 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
-- 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")
map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)")
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 })
pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr })
end
-- Global LSP defaults
vim.lsp.config("*", {
on_attach = on_attach,
capabilities = (function()
local caps = vim.lsp.protocol.make_client_capabilities()
caps.textDocument = caps.textDocument or {}
caps.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
return caps
end)(),
on_attach = on_attach,
capabilities = require('blink.cmp').get_lsp_capabilities()
-- capabilities = (function()
-- local caps = vim.lsp.protocol.make_client_capabilities()
-- caps.textDocument = caps.textDocument or {}
-- caps.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }
-- return caps
-- end)(),
})
-- Server-specific tweaks
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = { globals = { "vim", "require" } },
completion = { callSnippet = "Replace" },
workspace = { checkThirdParty = false },
},
},
})
-- -- Server-specific tweaks
-- vim.lsp.config("lua_ls", {
-- settings = {
-- Lua = {
-- diagnostics = { globals = { "vim", "require" } },
-- completion = { callSnippet = "Replace" },
-- workspace = { checkThirdParty = false },
-- },
-- },
-- })
-- Enable servers (Neovim 0.11+)
vim.lsp.enable(lsp_servers)
-- Trigger omni (like cmp.complete)
vim.keymap.set("i", "<C-Space>", function()
if vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" then
return vim.api.nvim_replace_termcodes("<C-x><C-o>", true, true, true)
end
return ""
end, { expr = true, silent = true, desc = "Trigger omni-completion" })
-- Navigate popup menu
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" })
-- Enter to confirm when pum is visible, otherwise newline
vim.keymap.set("i", "<CR>", function()
if vim.fn.pumvisible() == 1 then
-- Confirm current selection; if none selected, accept first
return vim.api.nvim_replace_termcodes("<C-y>", true, true, true)
end
return vim.api.nvim_replace_termcodes("<CR>", true, true, true)
end, { expr = true, silent = true, desc = "Confirm completion or newline" })
-- Requires your existing LuaSnip setup and mappings
local ok_ls, ls = pcall(require, "luasnip")
if ok_ls then
-- Tab: if menu visible, next item; else snippet expand/jump; else literal Tab
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.fn.pumvisible() == 1 then
return vim.api.nvim_replace_termcodes("<C-n>", true, true, true)
elseif ls.expand_or_jumpable() then
return "<Plug>luasnip-expand-or-jump"
else
return "<Tab>"
end
end, { expr = true, silent = true, desc = "Next item / Snippet jump / Tab" })
-- Shift-Tab: if menu visible, prev item; else snippet jump back; else literal
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if vim.fn.pumvisible() == 1 then
return vim.api.nvim_replace_termcodes("<C-p>", true, true, true)
elseif ls.jumpable(-1) then
return "<Plug>luasnip-jump-prev"
else
return "<S-Tab>"
end
end, { expr = true, silent = true, desc = "Prev item / Snippet back / Shift-Tab" })
end
-- -- Trigger omni (like cmp.complete)
-- vim.keymap.set("i", "<C-Space>", function()
-- if vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" then
-- return vim.api.nvim_replace_termcodes("<C-x><C-o>", true, true, true)
-- end
-- return ""
-- end, { expr = true, silent = true, desc = "Trigger omni-completion" })
--
-- -- Navigate popup menu
-- 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" })
--
-- -- Enter to confirm when pum is visible, otherwise newline
-- vim.keymap.set("i", "<CR>", function()
-- if vim.fn.pumvisible() == 1 then
-- -- Confirm current selection; if none selected, accept first
-- return vim.api.nvim_replace_termcodes("<C-y>", true, true, true)
-- end
-- return vim.api.nvim_replace_termcodes("<CR>", true, true, true)
-- end, { expr = true, silent = true, desc = "Confirm completion or newline" })
--
-- -- Requires your existing LuaSnip setup and mappings
-- local ok_ls, ls = pcall(require, "luasnip")
-- if ok_ls then
-- -- Tab: if menu visible, next item; else snippet expand/jump; else literal Tab
-- vim.keymap.set({ "i", "s" }, "<Tab>", function()
-- if vim.fn.pumvisible() == 1 then
-- return vim.api.nvim_replace_termcodes("<C-n>", true, true, true)
-- elseif ls.expand_or_jumpable() then
-- return "<Plug>luasnip-expand-or-jump"
-- else
-- return "<Tab>"
-- end
-- end, { expr = true, silent = true, desc = "Next item / Snippet jump / Tab" })
--
-- -- Shift-Tab: if menu visible, prev item; else snippet jump back; else literal
-- vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
-- if vim.fn.pumvisible() == 1 then
-- return vim.api.nvim_replace_termcodes("<C-p>", true, true, true)
-- elseif ls.jumpable(-1) then
-- return "<Plug>luasnip-jump-prev"
-- else
-- return "<S-Tab>"
-- end
-- end, { expr = true, silent = true, desc = "Prev item / Snippet back / Shift-Tab" })
-- end

View File

@ -1,9 +1,9 @@
-- Ensure packs are added
vim.pack.add({
{ 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-lua/plenary.nvim", version = "master" },
{ src = "https://github.com/nvim-telescope/telescope.nvim", version = "master" },
-- 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
@ -42,10 +42,12 @@ local function telescope_setup()
telescope.setup({
pickers = {
find_files = {
theme = "ivy",
hidden = true,
prompt_prefix = "🔍 ",
},
live_grep = {
theme = "ivy",
hidden = true,
prompt_prefix = "🔍 ",
},

View File

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