diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 84b1661..e4dd6c5 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,8 +1,11 @@ { "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, + "auto-session": { "branch": "main", "commit": "00334ee24b9a05001ad50221c8daffbeedaa0842" }, "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" }, + "codecompanion.nvim": { "branch": "main", "commit": "01b2841d7791376e23728d9faf657fe999e6c209" }, "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, + "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "hardtime.nvim": { "branch": "main", "commit": "145b930954a3146cfb5b8a73cdcad42eb7d2740c" }, @@ -23,6 +26,7 @@ "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "render-markdown.nvim": { "branch": "main", "commit": "6f5a4c36d9383b2a916facaa63dcd573afa11ee8" }, "smear-cursor.nvim": { "branch": "main", "commit": "162703638203060b1d3412e73429d232bbd2627e" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua index b41acd2..f33b63d 100644 --- a/.config/nvim/lua/autocmd.lua +++ b/.config/nvim/lua/autocmd.lua @@ -12,13 +12,13 @@ vim.api.nvim_create_autocmd("TextYankPost", { end, }) -vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { - desc = "diagnostics on hold", - group = vim.api.nvim_create_augroup("diagnostics", { clear = true }), - callback = function() - vim.diagnostic.open_float(nil, { focus = false }) - end, -}) +-- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { +-- desc = "diagnostics on hold", +-- group = vim.api.nvim_create_augroup("diagnostics", { clear = true }), +-- callback = function() +-- vim.diagnostic.open_float(nil, { focus = false }) +-- end, +-- }) -- TODO: check if it interferes with C-s shortcut vim.api.nvim_create_autocmd({ "BufWritePre" }, { diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index e31dcf0..2b84907 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -1,8 +1,8 @@ -vim.keymap.set("n", "", ":w ++p", { desc = "save file" }) -vim.keymap.set("v", "", ":w ++p", { desc = "save file" }) +vim.keymap.set({ "n", "v" }, "", ":w ++p", { desc = "save file" }) +vim.keymap.set({ "n", "v" }, "", ":bufdo! w ++p", { desc = "save all buffers" }) vim.keymap.set("i", "", ":w ++pa", { desc = "save file" }) -vim.keymap.set("n", ";", ":", { desc = "command with ;" }) -vim.keymap.set("v", ";", ":", { desc = "command with ;" }) +vim.keymap.set("n", ";", ":", { desc = "command with ;" }) +vim.keymap.set("v", ";", ":", { desc = "command with ;" }) vim.keymap.set("n", "q", ":bd", { desc = "close buffer" }) vim.keymap.set("n", "Q", ":%bd", { desc = "close all buffers" }) vim.keymap.set({ "n", "v" }, "d", '"_d', { desc = "delete without cut" }) @@ -23,6 +23,9 @@ vim.keymap.set("n", "", 'echo "Use l to move!!"') vim.keymap.set("n", "", 'echo "Use k to move!!"') vim.keymap.set("n", "", 'echo "Use j to move!!"') +vim.keymap.set("n", "", "", { silent = true, desc = "go back with mouse" }) +vim.keymap.set("n", "", "", { silent = true, desc = "go forward with mouse" }) + -- Keybindings to make split navigation easier. -- Use CTRL+ to switch between windows -- @@ -39,7 +42,7 @@ vim.keymap.set("v", "", function() -- get contents of visual selection -- handle unpack deprecation table.unpack = table.unpack or unpack - function get_visual() + local function get_visual() local _, ls, cs = table.unpack(vim.fn.getpos("v")) local _, le, ce = table.unpack(vim.fn.getpos(".")) return vim.api.nvim_buf_get_text(0, ls - 1, cs - 1, le - 1, ce, {}) @@ -51,3 +54,16 @@ vim.keymap.set("v", "", function() -- send parsed substitution command to command line vim.api.nvim_input(":%s/" .. pattern .. "//") end) + +-- Show virtual lines diagnostics and hide when moved +vim.keymap.set("n", "d", function() + vim.diagnostic.config({ virtual_lines = { current_line = true }, virtual_text = false }) + + vim.api.nvim_create_autocmd("CursorMoved", { + group = vim.api.nvim_create_augroup("line-diagnostics", { clear = true }), + callback = function() + vim.diagnostic.config({ virtual_lines = false, virtual_text = true }) + return true + end, + }) +end) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua index 1f9baeb..d7ebfb7 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/options.lua @@ -82,3 +82,5 @@ vim.opt.splitright = true vim.opt.splitbelow = true vim.opt.cmdheight = 0 + +vim.diagnostic.config({ virtual_text = true, underline = false }) diff --git a/.config/nvim/lua/plugins/blink.lua b/.config/nvim/lua/plugins/blink.lua index a510e79..83e45f1 100644 --- a/.config/nvim/lua/plugins/blink.lua +++ b/.config/nvim/lua/plugins/blink.lua @@ -6,19 +6,30 @@ return { version = "1.*", opts = { fuzzy = { - implementation = "rust", + -- implementation = "rust", use_frecency = true, use_proximity = true, use_unsafe_no_lock = false, sorts = { - -- (optionally) always prioritize exact matches + function(a, b) + if (a.client_name == nil or b.client_name == nil) or (a.client_name == b.client_name) then + return + end + return b.client_name == "emmet_language_server" + end, "exact", "score", "sort_text", }, }, - keymap = { preset = "enter" }, + keymap = { + preset = "enter", + [""] = { "hide", "show", "fallback" }, + }, completion = { + trigger = { + -- show_in_snippet = false, + }, -- Disable showing for all alphanumeric keywords by default. Prefer LSP specific trigger -- characters. -- trigger = { show_on_keyword = false }, @@ -48,6 +59,22 @@ return { -- make lazydev completions top priority (see `:h blink.cmp`) score_offset = 100, }, + snippets = { + min_keyword_length = 1, + score_offset = 4, + }, + lsp = { + min_keyword_length = 3, + score_offset = 3, + }, + path = { + min_keyword_length = 3, + score_offset = 2, + }, + buffer = { + min_keyword_length = 5, + score_offset = 1, + }, }, }, signature = { enabled = true }, diff --git a/.config/nvim/lua/plugins/codecompanion.lua b/.config/nvim/lua/plugins/codecompanion.lua new file mode 100644 index 0000000..644b1ca --- /dev/null +++ b/.config/nvim/lua/plugins/codecompanion.lua @@ -0,0 +1,95 @@ +return { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "j-hui/fidget.nvim", + }, + opts = { + strategies = { + chat = { + adapter = "gemini", + }, + inline = { + adapter = "gemini", + }, + cmd = { + adapter = "gemini", + }, + }, + adapters = { + llama3 = function() + return require("codecompanion.adapters").extend("ollama", { + name = "llama3", -- Give this adapter a different name to differentiate it from the default ollama adapter + schema = { + model = { + default = "llama3.1:latest", + }, + num_ctx = { + default = 16384, + }, + num_predict = { + default = -1, + }, + }, + }) + end, + qwen3 = function() + return require("codecompanion.adapters").extend("ollama", { + name = "qwen3", -- Give this adapter a different name to differentiate it from the default ollama adapter + schema = { + model = { + default = "qwen3:1.7b", + }, + }, + }) + end, + anthropic = function() + return require("codecompanion.adapters").extend("anthropic", { + env = { + api_key = "MY_OTHER_ANTHROPIC_KEY", + }, + }) + end, + gemini = function() + return require("codecompanion.adapters").extend("gemini", { + env = { + api_key = "AIzaSyCpXubVJ2ls6PgFjIjpIE9FDBIbGTuXt7U", + }, + }) + end, + }, + }, + config = function(_, opts) + require("codecompanion").setup(opts) + + local progress = require("fidget.progress") + local handles = {} + local group = vim.api.nvim_create_augroup("CodeCompanionFidget", {}) + + vim.api.nvim_create_autocmd("User", { + pattern = "CodeCompanionRequestStarted", + group = group, + callback = function(e) + handles[e.data.id] = progress.handle.create({ + title = "CodeCompanion", + message = "Thinking...", + lsp_client = { name = e.data.adapter.formatted_name }, + }) + end, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "CodeCompanionRequestFinished", + group = group, + callback = function(e) + local h = handles[e.data.id] + if h then + h.message = e.data.status == "success" and "Done" or "Failed" + h:finish() + handles[e.data.id] = nil + end + end, + }) + end, +} diff --git a/.config/nvim/lua/plugins/flash.lua b/.config/nvim/lua/plugins/flash.lua index 15cdff8..e101434 100644 --- a/.config/nvim/lua/plugins/flash.lua +++ b/.config/nvim/lua/plugins/flash.lua @@ -6,11 +6,14 @@ return { autojump = true, }, label = { - before = true, - after = false, - min_pattern_length = 0, + -- before = true, + after = true, + min_pattern_length = 1, style = "overlay", }, + search = { + mode = "search", + }, }, keys = { { diff --git a/.config/nvim/lua/plugins/hardtime.lua b/.config/nvim/lua/plugins/hardtime.lua index 2f4eaf3..0643a9f 100644 --- a/.config/nvim/lua/plugins/hardtime.lua +++ b/.config/nvim/lua/plugins/hardtime.lua @@ -3,6 +3,7 @@ return { lazy = false, dependencies = { "MunifTanjim/nui.nvim" }, opts = { + disable_mouse = false, disabled_keys = { [""] = false, [""] = false, diff --git a/.config/nvim/lua/plugins/luasnip.lua b/.config/nvim/lua/plugins/luasnip.lua index 3f87323..59c09e1 100644 --- a/.config/nvim/lua/plugins/luasnip.lua +++ b/.config/nvim/lua/plugins/luasnip.lua @@ -13,42 +13,45 @@ return { }) require("luasnip.loaders.from_vscode").lazy_load() + + require("luasnip").filetype_extend("typescript", { "javascript" }) + require("luasnip").filetype_extend("typescriptreact", { "javascript" }) end, - keys = { - { - "rs", - ":source ~/.config/nvim/lua/snippets.lua", - desc = "[R]eload [s]nippets", - }, - { - "", - function() - if require("luasnip").locally_jumpable(1) then - require("luasnip").jump(1) - end - end, - mode = { "i", "s" }, - desc = "next snippet placeholder", - }, - { - "", - function() - if require("luasnip").locally_jumpable(-1) then - require("luasnip").jump(-1) - end - end, - mode = { "i", "s" }, - desc = "prev snippet placeholder", - }, - { - "", - function() - if require("luasnip").choice_active() then - require("luasnip").change_choice(1) - end - end, - mode = { "i", "s" }, - desc = "prev snippet placeholder", - }, - }, + -- keys = { + -- { + -- "rs", + -- ":source ~/.config/nvim/lua/snippets.lua", + -- desc = "[R]eload [s]nippets", + -- }, + -- { + -- "", + -- function() + -- if require("luasnip").locally_jumpable(1) then + -- require("luasnip").jump(1) + -- end + -- end, + -- mode = { "i", "s" }, + -- desc = "next snippet placeholder", + -- }, + -- { + -- "", + -- function() + -- if require("luasnip").locally_jumpable(-1) then + -- require("luasnip").jump(-1) + -- end + -- end, + -- mode = { "i", "s" }, + -- desc = "prev snippet placeholder", + -- }, + -- { + -- "", + -- function() + -- if require("luasnip").choice_active() then + -- require("luasnip").change_choice(1) + -- end + -- end, + -- mode = { "i", "s" }, + -- desc = "prev snippet placeholder", + -- }, + -- }, } diff --git a/.config/nvim/lua/plugins/markdown.lua b/.config/nvim/lua/plugins/markdown.lua new file mode 100644 index 0000000..b6264b8 --- /dev/null +++ b/.config/nvim/lua/plugins/markdown.lua @@ -0,0 +1,4 @@ +return { + "MeanderingProgrammer/render-markdown.nvim", + ft = { "markdown", "codecompanion" }, +} diff --git a/.config/nvim/lua/plugins/session.lua b/.config/nvim/lua/plugins/session.lua new file mode 100644 index 0000000..8ec58b2 --- /dev/null +++ b/.config/nvim/lua/plugins/session.lua @@ -0,0 +1,12 @@ +return { + "rmagatti/auto-session", + lazy = false, + + ---enables autocomplete for opts + ---@module "auto-session" + ---@type AutoSession.Config + opts = { + suppressed_dirs = { "~/", "~/Projects", "~/Downloads", "/" }, + -- log_level = 'debug', + }, +} diff --git a/.config/nvim/lua/snippets.lua b/.config/nvim/lua/snippets.lua index 10d2ab6..f5fc472 100644 --- a/.config/nvim/lua/snippets.lua +++ b/.config/nvim/lua/snippets.lua @@ -39,19 +39,57 @@ ls.add_snippets("lua", { }) -- js/ts/sx snippets +local allJsFts = { + "javascript", + "typescript", + "typescriptreact", + "javascriptreact", +} +local tsFts = { + "typescriptreact", + "typescript", +} local import = s( "im", fmt("import {name} from '{module}';", { module = i(1), - name = c(2, { i(nil), fmt("{{{}}}", { i(1) }) }), + name = c(2, { i(1), fmt("{{{}}}", { i(1) }) }), }) ) +local field = s( + "fi", + fmt("{name}: {type};", { + name = i(1), + type = i(2), + }) +) +local constF = s( + "cf", + fmt( + [[{export}const {name}{type} = ({args}){ret} => {{ + {body} +}}]], + { + export = c(1, { t("export "), i(1) }), + name = i(2), + type = i(3), + args = i(3), + ret = i(4), + body = i(5), + } + ) +) -ls.add_snippets("typescript", { - import, -}) +for _, ft in ipairs(tsFts) do + ls.add_snippets(ft, { + constF, + field, + }) +end -ls.add_snippets("typescriptreact", { - import, -}) +for _, ft in ipairs(allJsFts) do + ls.add_snippets(ft, { + import, + }) +end diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua index 10203c1..951221c 100644 --- a/.config/wezterm/wezterm.lua +++ b/.config/wezterm/wezterm.lua @@ -1,14 +1,26 @@ -- Pull in the wezterm API local wezterm = require("wezterm") +local act = wezterm.action -- This will hold the configuration. local config = wezterm.config_builder() --- This is where you actually apply your config choices - -- For example, changing the color scheme: config.color_scheme = "tokyonight_night" - +config.alternate_buffer_wheel_scroll_speed = 10 +-- Change mouse scroll amount +config.mouse_bindings = { + { + event = { Down = { streak = 1, button = { WheelUp = 1 } } }, + mods = "NONE", + action = act.ScrollByLine(-10), + }, + { + event = { Down = { streak = 1, button = { WheelDown = 1 } } }, + mods = "NONE", + action = act.ScrollByLine(10), + }, +} config.font = wezterm.font({ family = "Iosevka Nerd Font", weight = "Regular", style = "Italic" }) config.font_size = 11