From bc80157fa97d30ad33294804ec493cd43b15c1f2 Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Thu, 6 Nov 2025 00:34:29 +0300 Subject: [PATCH] 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 --- nvim/lua/configs/lspconfig.lua | 99 ++++++++++++++------------------ nvim/lua/mappings.lua | 24 +++++--- nvim/lua/plugins/auto-save.lua | 43 ++++++++++++++ nvim/lua/plugins/hop.lua | 41 +++++++------ nvim/lua/plugins/live-server.lua | 8 +++ nvim/lua/plugins/windsurf.lua | 30 ++++++++++ nvim/lua/snippets/html.lua | 40 +++++++++++++ nvim/lua/themes/kolyan.lua | 2 +- 8 files changed, 204 insertions(+), 83 deletions(-) create mode 100644 nvim/lua/plugins/auto-save.lua create mode 100644 nvim/lua/plugins/live-server.lua create mode 100644 nvim/lua/plugins/windsurf.lua create mode 100644 nvim/lua/snippets/html.lua diff --git a/nvim/lua/configs/lspconfig.lua b/nvim/lua/configs/lspconfig.lua index af439e1..e23c977 100644 --- a/nvim/lua/configs/lspconfig.lua +++ b/nvim/lua/configs/lspconfig.lua @@ -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') diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua index 965b71b..5820cfe 100644 --- a/nvim/lua/mappings.lua +++ b/nvim/lua/mappings.lua @@ -14,10 +14,13 @@ local base46 = require "base46" vim.keymap.set("n", "tt", base46.toggle_transparency) -- Toggle wrap -vim.keymap.set("n", "ww", function () +vim.keymap.set("n", "tw", function () vim.wo.wrap = not vim.wo.wrap end) +-- Togle autosave +vim.api.nvim_set_keymap("n", "ta", ":ASToggle", { desc = "Autosave Toggle" }) + -- Debbuger binds -- local dap = require "dap" -- vim.keymap.set("n", "pb", dap.toggle_breakpoint, { desc = "Dap Toggle breakpoint" }) @@ -96,17 +99,17 @@ map("t", "", "", { 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", "tv", function() require('vscode').load('dark') end) @@ -116,6 +119,9 @@ vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "Lsp Rename" }) vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { desc = "Lsp Code Action" }) vim.keymap.set("n", "ci", vim.lsp.buf.implementation, { desc = "Lsp Implementation" }) +-- load Windsurf +vim.keymap.set("n", "ws", function () require("windsurf").enabled = true end, { desc = "Windsurf" }) + -- cdproj vim.keymap.set('n', 'cp', 'CdProject', { desc = 'Project Switch directory directory' }) diff --git a/nvim/lua/plugins/auto-save.lua b/nvim/lua/plugins/auto-save.lua new file mode 100644 index 0000000..32638e3 --- /dev/null +++ b/nvim/lua/plugins/auto-save.lua @@ -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, + + } +} diff --git a/nvim/lua/plugins/hop.lua b/nvim/lua/plugins/hop.lua index 6218dfa..74570ea 100644 --- a/nvim/lua/plugins/hop.lua +++ b/nvim/lua/plugins/hop.lua @@ -1,20 +1,27 @@ return { - { - 'smoka7/hop.nvim', - version = "*", - opts = { - multi_windows = true, - keys = 'asdfghjklcvnmqp', --'etovxqpdygfblzhckisuran', - uppercase_labels = true - }, - keys = { - { - "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 = { + { + "gg", + function() + require("hop").hint_words() + end, + mode = {"n", "x", "o", "v"} + }, + { + "gf", + function () + require("hop").hint_patterns() + end, + mode = {"n", "x", "o", "v"} + } + } } - } } diff --git a/nvim/lua/plugins/live-server.lua b/nvim/lua/plugins/live-server.lua new file mode 100644 index 0000000..422d624 --- /dev/null +++ b/nvim/lua/plugins/live-server.lua @@ -0,0 +1,8 @@ +return { + { + "barrett-ruth/live-server.nvim", + build = 'pnpm add -g live-server', + cmd = { 'LiveServerStart', 'LiveServerStop' }, + config = true + } +} diff --git a/nvim/lua/plugins/windsurf.lua b/nvim/lua/plugins/windsurf.lua new file mode 100644 index 0000000..6449267 --- /dev/null +++ b/nvim/lua/plugins/windsurf.lua @@ -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", "", function() + return vim.fn["codeium#Accept"]() + end, { expr = true }) + -- Complete next word + vim.keymap.set("i", "", function() + return vim.fn["codeium#AcceptNextWord"]() + end, { expr = true }) + -- Complete line + vim.keymap.set("i", "", function() + return vim.fn["codeium#AcceptNextLine"]() + end, { expr = true }) + -- Next + vim.keymap.set("i", "", function() + return vim.fn["codeium#CycleCompletions"](1) + end, { expr = true }) + -- Previous + vim.keymap.set("i", "", function() + return vim.fn["codeium#Clear"]() + end, { expr = true }) + end +} + diff --git a/nvim/lua/snippets/html.lua b/nvim/lua/snippets/html.lua new file mode 100644 index 0000000..c155b24 --- /dev/null +++ b/nvim/lua/snippets/html.lua @@ -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(""), + t({"", "", ""}), + t({"", ""}), + t({" ", ""}), + t({" ", ""}), + t({" "}), i(2, "Document"), t({"", ""}), + t({"", ""}), + t({"", ""}), + i(0), + t({"", "", ""}), + t({""}) + }), + + -- Alternative version using fmt for cleaner formatting + s("!html", fmt([[ + + + + + + {} + + + {} + + + ]], { + i(1, "en"), + i(2, "Document"), + i(0) + })) +} diff --git a/nvim/lua/themes/kolyan.lua b/nvim/lua/themes/kolyan.lua index 1cb516c..cbf13d1 100644 --- a/nvim/lua/themes/kolyan.lua +++ b/nvim/lua/themes/kolyan.lua @@ -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