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:
@@ -1,68 +1,55 @@
|
|||||||
-- load defaults i.e lua_lsp
|
|
||||||
require("nvchad.configs.lspconfig").defaults()
|
require("nvchad.configs.lspconfig").defaults()
|
||||||
|
|
||||||
local lspconfig = require "lspconfig"
|
|
||||||
|
|
||||||
-- EXAMPLE
|
|
||||||
local servers = {
|
local servers = {
|
||||||
"arduino_language_server",
|
"arduino_language_server",
|
||||||
"ccls", --C/C++
|
"ccls",
|
||||||
-- "csharp_ls",
|
"cssls",
|
||||||
"cssls", --CSS
|
"css_variables",
|
||||||
"css_variables",
|
"dartls",
|
||||||
"dartls", --Dart
|
"gopls",
|
||||||
"gopls",
|
"html",
|
||||||
"html",
|
"marksman",
|
||||||
"marksman",
|
"rust_analyzer",
|
||||||
-- "pylsp",
|
"svelte",
|
||||||
"rust_analyzer",
|
"sqls",
|
||||||
"svelte",
|
"ts_ls"
|
||||||
"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 },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local nvlsp = require "nvchad.configs.lspconfig"
|
local nvlsp = require "nvchad.configs.lspconfig"
|
||||||
|
|
||||||
-- lsps with default config
|
vim.lsp.config.omnisharp = {
|
||||||
for _, lsp in ipairs(servers) do
|
cmd = { "dotnet", "/home/greg/.local/share/nvim/mason/packages/omnisharp/libexec/OmniSharp.dll" },
|
||||||
lspconfig[lsp].setup {
|
|
||||||
on_attach = nvlsp.on_attach,
|
on_attach = nvlsp.on_attach,
|
||||||
on_init = nvlsp.on_init,
|
on_init = nvlsp.on_init,
|
||||||
capabilities = nvlsp.capabilities,
|
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
|
end
|
||||||
|
|
||||||
-- configuring single server, example: typescript
|
for _, lsp in ipairs(servers) do
|
||||||
-- lspconfig.tsserver.setup {
|
vim.lsp.enable(lsp)
|
||||||
-- on_attach = nvlsp.on_attach,
|
end
|
||||||
-- on_init = nvlsp.on_init,
|
vim.lsp.enable('omnisharp')
|
||||||
-- capabilities = nvlsp.capabilities,
|
vim.lsp.enable('pylsp')
|
||||||
-- }
|
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ local base46 = require "base46"
|
|||||||
vim.keymap.set("n", "<leader>tt", base46.toggle_transparency)
|
vim.keymap.set("n", "<leader>tt", base46.toggle_transparency)
|
||||||
|
|
||||||
-- Toggle wrap
|
-- Toggle wrap
|
||||||
vim.keymap.set("n", "<leader>ww", function ()
|
vim.keymap.set("n", "<leader>tw", function ()
|
||||||
vim.wo.wrap = not vim.wo.wrap
|
vim.wo.wrap = not vim.wo.wrap
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Togle autosave
|
||||||
|
vim.api.nvim_set_keymap("n", "<leader>ta", ":ASToggle<CR>", { desc = "Autosave Toggle" })
|
||||||
|
|
||||||
-- Debbuger binds
|
-- Debbuger binds
|
||||||
-- local dap = require "dap"
|
-- local dap = require "dap"
|
||||||
-- vim.keymap.set("n", "<space>pb", dap.toggle_breakpoint, { desc = "Dap Toggle breakpoint" })
|
-- 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 hop = require('hop')
|
||||||
local directions = require('hop.hint').HintDirection
|
local directions = require('hop.hint').HintDirection
|
||||||
vim.keymap.set('', 'f', function()
|
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})
|
end, {remap=true})
|
||||||
vim.keymap.set('', 'F', function()
|
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})
|
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
|
-- themes
|
||||||
vim.keymap.set("n", "<leader>tv", function() require('vscode').load('dark') end)
|
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>ca", vim.lsp.buf.code_action, { desc = "Lsp Code Action" })
|
||||||
vim.keymap.set("n", "<leader>ci", vim.lsp.buf.implementation, { desc = "Lsp Implementation" })
|
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
|
-- cdproj
|
||||||
vim.keymap.set('n', '<leader>cp', '<cmd>CdProject<cr>', { desc = 'Project Switch directory directory' })
|
vim.keymap.set('n', '<leader>cp', '<cmd>CdProject<cr>', { desc = 'Project Switch directory directory' })
|
||||||
|
|
||||||
|
|||||||
43
nvim/lua/plugins/auto-save.lua
Normal file
43
nvim/lua/plugins/auto-save.lua
Normal 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,
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,27 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
'smoka7/hop.nvim',
|
'smoka7/hop.nvim',
|
||||||
version = "*",
|
version = "*",
|
||||||
opts = {
|
opts = {
|
||||||
multi_windows = true,
|
multi_windows = true,
|
||||||
keys = 'asdfghjklcvnmqp', --'etovxqpdygfblzhckisuran',
|
keys = 'asdfghjklcvnmqp', --'etovxqpdygfblzhckisuran',
|
||||||
uppercase_labels = true
|
uppercase_labels = true
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>gg",
|
"<leader>gg",
|
||||||
function()
|
function()
|
||||||
require("hop").hint_words()
|
require("hop").hint_words()
|
||||||
end,
|
end,
|
||||||
mode = {"n", "x", "o", "v"}
|
mode = {"n", "x", "o", "v"}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"<leader>gf",
|
||||||
|
function ()
|
||||||
|
require("hop").hint_patterns()
|
||||||
|
end,
|
||||||
|
mode = {"n", "x", "o", "v"}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
8
nvim/lua/plugins/live-server.lua
Normal file
8
nvim/lua/plugins/live-server.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"barrett-ruth/live-server.nvim",
|
||||||
|
build = 'pnpm add -g live-server',
|
||||||
|
cmd = { 'LiveServerStart', 'LiveServerStop' },
|
||||||
|
config = true
|
||||||
|
}
|
||||||
|
}
|
||||||
30
nvim/lua/plugins/windsurf.lua
Normal file
30
nvim/lua/plugins/windsurf.lua
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
40
nvim/lua/snippets/html.lua
Normal file
40
nvim/lua/snippets/html.lua
Normal 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)
|
||||||
|
}))
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@ M.base_30 = {
|
|||||||
M.base_16 = {
|
M.base_16 = {
|
||||||
base00 = "#1c1c1d", -- background
|
base00 = "#1c1c1d", -- background
|
||||||
base01 = "#1a1d21",
|
base01 = "#1a1d21",
|
||||||
base02 = "#23262a",
|
base02 = "#43464a",
|
||||||
base03 = "#5b5e62",
|
base03 = "#5b5e62",
|
||||||
base04 = "#323539",
|
base04 = "#323539",
|
||||||
base05 = "#878b96", -- foreground
|
base05 = "#878b96", -- foreground
|
||||||
|
|||||||
Reference in New Issue
Block a user