feat: add auto-save plugin with toggle mapping;

feat: windsurf is back;
feat: add html snippet for boilerplate;
refactor: lsp config due to deprecation;
refactor: update hop mappings to current-line only with offsets;
chore: adjust base02 color in kolyan theme
This commit is contained in:
2025-11-06 00:34:29 +03:00
parent 070e44a5e0
commit bc80157fa9
8 changed files with 204 additions and 83 deletions

View File

@@ -1,68 +1,55 @@
-- load defaults i.e lua_lsp
require("nvchad.configs.lspconfig").defaults()
local lspconfig = require "lspconfig"
-- EXAMPLE
local servers = {
"arduino_language_server",
"ccls", --C/C++
-- "csharp_ls",
"cssls", --CSS
"css_variables",
"dartls", --Dart
"gopls",
"html",
"marksman",
-- "pylsp",
"rust_analyzer",
"svelte",
"sqlls", --SQL
"ts_ls" --TypeScript
}
lspconfig.omnisharp.setup {
cmd = { "dotnet", "/home/greg/.local/share/nvim/mason/packages/omnisharp/libexec/OmniSharp.dll"},
}
-- lspconfig.rust_analyzer.setup {
-- settings = {
-- ['rust-analyzer'] = {
-- diagnostics = {
-- enabled = false
-- }
-- }
-- }
-- }
lspconfig.pylsp.setup {
cmd = { "/home/greg/.venv312/bin/pylsp" },
settings = {
pylsp = {
plugins = {
black = { enabled = true },
-- pylint = { enabled = true, executable = "pylint", args = { "--jobs=4" } },
pycodestyle = { enabled = false },
pylsp_mypy = { enabled = true },
}
}
}
"arduino_language_server",
"ccls",
"cssls",
"css_variables",
"dartls",
"gopls",
"html",
"marksman",
"rust_analyzer",
"svelte",
"sqls",
"ts_ls"
}
local nvlsp = require "nvchad.configs.lspconfig"
-- lsps with default config
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
vim.lsp.config.omnisharp = {
cmd = { "dotnet", "/home/greg/.local/share/nvim/mason/packages/omnisharp/libexec/OmniSharp.dll" },
on_attach = nvlsp.on_attach,
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
}
}
vim.lsp.config.pylsp = {
cmd = { "/home/greg/.venv312/bin/pylsp" },
settings = {
pylsp = {
plugins = {
black = { enabled = true },
pycodestyle = { enabled = false },
pylsp_mypy = { enabled = true },
}
}
},
on_attach = nvlsp.on_attach,
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
}
for _, lsp in ipairs(servers) do
vim.lsp.config[lsp] = {
on_attach = nvlsp.on_attach,
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
}
end
-- configuring single server, example: typescript
-- lspconfig.tsserver.setup {
-- on_attach = nvlsp.on_attach,
-- on_init = nvlsp.on_init,
-- capabilities = nvlsp.capabilities,
-- }
for _, lsp in ipairs(servers) do
vim.lsp.enable(lsp)
end
vim.lsp.enable('omnisharp')
vim.lsp.enable('pylsp')

View File

@@ -14,10 +14,13 @@ local base46 = require "base46"
vim.keymap.set("n", "<leader>tt", base46.toggle_transparency)
-- Toggle wrap
vim.keymap.set("n", "<leader>ww", function ()
vim.keymap.set("n", "<leader>tw", function ()
vim.wo.wrap = not vim.wo.wrap
end)
-- Togle autosave
vim.api.nvim_set_keymap("n", "<leader>ta", ":ASToggle<CR>", { desc = "Autosave Toggle" })
-- Debbuger binds
-- local dap = require "dap"
-- vim.keymap.set("n", "<space>pb", dap.toggle_breakpoint, { desc = "Dap Toggle breakpoint" })
@@ -96,17 +99,17 @@ map("t", "<C-Esc>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" })
local hop = require('hop')
local directions = require('hop.hint').HintDirection
vim.keymap.set('', 'f', function()
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true })
end, {remap=true})
vim.keymap.set('', 'F', function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true })
end, {remap=true})
vim.keymap.set('', 't', function()
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true, hint_offset = -1 })
end, {remap=true})
vim.keymap.set('', 'T', function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 })
end, {remap=true})
-- vim.keymap.set('', 't', function()
-- hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false, hint_offset = -1 })
-- end, {remap=true})
-- vim.keymap.set('', 'T', function()
-- hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false, hint_offset = 1 })
-- end, {remap=true})
-- themes
vim.keymap.set("n", "<leader>tv", function() require('vscode').load('dark') end)
@@ -116,6 +119,9 @@ vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Lsp Rename" })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Lsp Code Action" })
vim.keymap.set("n", "<leader>ci", vim.lsp.buf.implementation, { desc = "Lsp Implementation" })
-- load Windsurf
vim.keymap.set("n", "<leader>ws", function () require("windsurf").enabled = true end, { desc = "Windsurf" })
-- cdproj
vim.keymap.set('n', '<leader>cp', '<cmd>CdProject<cr>', { desc = 'Project Switch directory directory' })

View File

@@ -0,0 +1,43 @@
return {
{
"okuuva/auto-save.nvim",
config = function()
require("auto-save").setup {
{
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
execution_message = {
message = function() -- message to print on save
return ("Auto-saved at " .. vim.fn.strftime("%H:%M:%S"))
end,
dim = 0.18, -- dim the color of `message`
cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea
},
trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events
-- function that determines whether to save the current buffer or not
-- return true: if buffer is ok to be saved
-- return false: if it's not ok to be saved
condition = function(buf)
local fn = vim.fn
local utils = require("auto-save.utils.data")
if
fn.getbufvar(buf, "&modifiable") == 1 and
utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
return true -- met condition(s), can save
end
return false -- can't save
end,
write_all_buffers = false, -- write all buffers when the current one meets `condition`
debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
callbacks = { -- functions to be executed at different intervals
enabling = nil, -- ran when enabling auto-save
disabling = nil, -- ran when disabling auto-save
before_asserting_save = nil, -- ran before checking `condition`
before_saving = nil, -- ran before doing the actual save
after_saving = nil -- ran after doing the actual save
}
}}
end,
}
}

View File

@@ -1,20 +1,27 @@
return {
{
'smoka7/hop.nvim',
version = "*",
opts = {
multi_windows = true,
keys = 'asdfghjklcvnmqp', --'etovxqpdygfblzhckisuran',
uppercase_labels = true
},
keys = {
{
"<leader>gg",
function()
require("hop").hint_words()
end,
mode = {"n", "x", "o", "v"}
}
{
'smoka7/hop.nvim',
version = "*",
opts = {
multi_windows = true,
keys = 'asdfghjklcvnmqp', --'etovxqpdygfblzhckisuran',
uppercase_labels = true
},
keys = {
{
"<leader>gg",
function()
require("hop").hint_words()
end,
mode = {"n", "x", "o", "v"}
},
{
"<leader>gf",
function ()
require("hop").hint_patterns()
end,
mode = {"n", "x", "o", "v"}
}
}
}
}
}

View File

@@ -0,0 +1,8 @@
return {
{
"barrett-ruth/live-server.nvim",
build = 'pnpm add -g live-server',
cmd = { 'LiveServerStart', 'LiveServerStop' },
config = true
}
}

View File

@@ -0,0 +1,30 @@
return {
"Exafunction/windsurf.vim",
event = 'BufEnter',
enabled = false,
init = function()
vim.g.codeium_disable_bindings = 1
-- Completion
vim.keymap.set("i", "<S-Enter>", function()
return vim.fn["codeium#Accept"]()
end, { expr = true })
-- Complete next word
vim.keymap.set("i", "<M-Enter>", function()
return vim.fn["codeium#AcceptNextWord"]()
end, { expr = true })
-- Complete line
vim.keymap.set("i", "<M-\\>", function()
return vim.fn["codeium#AcceptNextLine"]()
end, { expr = true })
-- Next
vim.keymap.set("i", "<M-]>", function()
return vim.fn["codeium#CycleCompletions"](1)
end, { expr = true })
-- Previous
vim.keymap.set("i", "<M-[>", function()
return vim.fn["codeium#Clear"]()
end, { expr = true })
end
}

View File

@@ -0,0 +1,40 @@
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt
return {
s("!", {
t("<!DOCTYPE html>"),
t({"", "<html lang=\""}), i(1, "en"), t({"\" >", ""}),
t({"<head>", ""}),
t({" <meta charset=\"UTF-8\">", ""}),
t({" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">", ""}),
t({" <title>"}), i(2, "Document"), t({"</title>", ""}),
t({"</head>", ""}),
t({"<body>", ""}),
i(0),
t({"", "</body>", ""}),
t({"</html>"})
}),
-- Alternative version using fmt for cleaner formatting
s("!html", fmt([[
<!DOCTYPE html>
<html lang="{}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{}</title>
</head>
<body>
{}
</body>
</html>
]], {
i(1, "en"),
i(2, "Document"),
i(0)
}))
}

View File

@@ -36,7 +36,7 @@ M.base_30 = {
M.base_16 = {
base00 = "#1c1c1d", -- background
base01 = "#1a1d21",
base02 = "#23262a",
base02 = "#43464a",
base03 = "#5b5e62",
base04 = "#323539",
base05 = "#878b96", -- foreground