ciao
This commit is contained in:
parent
28598c5e1d
commit
7e84c2f591
@ -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
|
||||
|
||||
0
nvim/after/ftplugin/lua.lua
Normal file
0
nvim/after/ftplugin/lua.lua
Normal 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")
|
||||
|
||||
@ -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,
|
||||
})
|
||||
|
||||
28
nvim/lua/kanopo/plugins/cmp.lua
Normal file
28
nvim/lua/kanopo/plugins/cmp.lua
Normal 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,
|
||||
})
|
||||
@ -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")
|
||||
|
||||
@ -3,8 +3,10 @@ vim.pack.add({
|
||||
{ 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/saghen/blink.cmp", version = "1.*" },
|
||||
-- { src = "https://github.com/L3MON4D3/LuaSnip" },
|
||||
-- { src = "https://github.com/rafamadriz/friendly-snippets" },
|
||||
})
|
||||
|
||||
-- Load packs early (guard API)
|
||||
@ -58,6 +60,20 @@ do
|
||||
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
|
||||
@ -69,22 +85,6 @@ local function on_attach(_, bufnr)
|
||||
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc })
|
||||
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",
|
||||
})
|
||||
|
||||
-- Telescope-powered LSP navigation (loads telescope.builtin on demand)
|
||||
local function tb(fn)
|
||||
return function()
|
||||
@ -117,74 +117,76 @@ local function on_attach(_, 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)(),
|
||||
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
|
||||
|
||||
@ -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 = "🔍 ",
|
||||
},
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
|
||||
const ciao = () => {
|
||||
console.log("ciao")
|
||||
}
|
||||
|
||||
ciao()
|
||||
Loading…
x
Reference in New Issue
Block a user