diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index e4c32d5..083aac1 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -2,3 +2,4 @@ require("options") require("config.lazy") require("keymaps") require("autocmd") +require("snippets") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 3a92e83..84b1661 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,24 +1,29 @@ { - "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, - "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, + "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, + "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, + "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" }, + "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "github-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" }, + "hardtime.nvim": { "branch": "main", "commit": "145b930954a3146cfb5b8a73cdcad42eb7d2740c" }, "js-i18n.nvim": { "branch": "main", "commit": "124f22f91d51e85641ba10e9a32f3b858394c2dd" }, - "lackluster.nvim": { "branch": "main", "commit": "d2519d14b2b6e9eef05752d5d4486ed5c48d6178" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, - "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, - "nightfox.nvim": { "branch": "main", "commit": "ba47d4b4c5ec308718641ba7402c143836f35aa9" }, + "lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "67da97f8c2fd12d05427bb485ce07ee6418e0a51" }, + "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "mentor.nvim": { "branch": "main", "commit": "c89148673b56e96fab5d201594457828be5dae96" }, + "neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" }, + "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, + "nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" }, "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, - "nvim-lspconfig": { "branch": "master", "commit": "4bc481b6f0c0cf3671fc894debd0e00347089a4e" }, - "nvim-surround": { "branch": "main", "commit": "0e62500b98f4513feaaf7425c135472457ea5b7d" }, - "nvim-treesitter": { "branch": "master", "commit": "28d480e0624b259095e56f353ec911f9f2a0f404" }, - "nvim-web-devicons": { "branch": "master", "commit": "2c2b4eafce6cdd0cb165036faa17396eff18f847" }, + "nvim-lspconfig": { "branch": "master", "commit": "b8e7957bde4cbb3cb25a13a62548f7c273b026e9" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-surround": { "branch": "main", "commit": "8dd9150ca7eae5683660ea20cec86edcd5ca4046" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "smear-cursor.nvim": { "branch": "main", "commit": "8820b313e49a018c7d56fc309c51363c0e9ae653" }, + "smear-cursor.nvim": { "branch": "main", "commit": "162703638203060b1d3412e73429d232bbd2627e" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua index 3e5126e..801b5d1 100644 --- a/.config/nvim/lua/config/lazy.lua +++ b/.config/nvim/lua/config/lazy.lua @@ -1,25 +1,23 @@ -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system { - "git", - "clone", - "--filter=blob:none", - "--branch=stable", - lazyrepo, - lazypath - } - if vim.v.shell_error ~= 0 then - error("Error cloning lazy.nvim:\n" .. out) - end + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + lazyrepo, + lazypath, + }) + if vim.v.shell_error ~= 0 then + error("Error cloning lazy.nvim:\n" .. out) + end end + vim.opt.rtp:prepend(lazypath) -require("lazy").setup( - { import = "plugins" }, - { install = { colorscheme = { "tokyonight-storm" } } } -) +require("lazy").setup({ import = "plugins" }, { install = { colorscheme = { "tokyonight-storm" } } }) diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 26af006..e31dcf0 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -6,7 +6,7 @@ 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" }) -vim.keymap.set({ "n", "v" }, "c", '"_c', { desc = "ddelete without cutelete without cut" }) +vim.keymap.set({ "n", "v" }, "c", '"_c', { desc = "delete without cut" }) vim.keymap.set({ "v", "n" }, "vv", "", { desc = "vv for visual block" }) vim.keymap.set("i", "jj", "", { silent = true, desc = "back to normal with jj" }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier @@ -32,6 +32,9 @@ vim.keymap.set("n", "", "", { desc = "Move focus to the right win vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) vim.keymap.set("n", "", "", { desc = "Move focus to the upper window" }) +vim.keymap.set("n", "", ":bprevious", { desc = "Previous buffer" }) +vim.keymap.set("n", "", ":bnext", { desc = "Next buffer" }) + vim.keymap.set("v", "", function() -- get contents of visual selection -- handle unpack deprecation diff --git a/.config/nvim/lua/plugins/blink.lua b/.config/nvim/lua/plugins/blink.lua index 3f2be65..a510e79 100644 --- a/.config/nvim/lua/plugins/blink.lua +++ b/.config/nvim/lua/plugins/blink.lua @@ -1,6 +1,8 @@ return { "saghen/blink.cmp", - dependencies = { "rafamadriz/friendly-snippets" }, + dependencies = { + { "L3MON4D3/LuaSnip", version = "v2.*" }, + }, version = "1.*", opts = { fuzzy = { @@ -15,11 +17,7 @@ return { "sort_text", }, }, - keymap = { - preset = "super-tab", - [""] = { "show", "show_documentation", "hide_documentation" }, - [""] = {}, - }, + keymap = { preset = "enter" }, completion = { -- Disable showing for all alphanumeric keywords by default. Prefer LSP specific trigger -- characters. @@ -39,9 +37,10 @@ return { scrollbar = false, }, }, + snippets = { preset = "luasnip" }, sources = { -- add lazydev to your completion providers - default = { "lazydev", "lsp", "path", "snippets", "buffer" }, + default = { "lazydev", "snippets", "lsp", "path", "buffer" }, providers = { lazydev = { name = "LazyDev", diff --git a/.config/nvim/lua/plugins/hardtime.lua b/.config/nvim/lua/plugins/hardtime.lua new file mode 100644 index 0000000..2f4eaf3 --- /dev/null +++ b/.config/nvim/lua/plugins/hardtime.lua @@ -0,0 +1,13 @@ +return { + "m4xshen/hardtime.nvim", + lazy = false, + dependencies = { "MunifTanjim/nui.nvim" }, + opts = { + disabled_keys = { + [""] = false, + [""] = false, + [""] = false, + [""] = false, + }, + }, +} diff --git a/.config/nvim/lua/plugins/luasnip.lua b/.config/nvim/lua/plugins/luasnip.lua new file mode 100644 index 0000000..3f87323 --- /dev/null +++ b/.config/nvim/lua/plugins/luasnip.lua @@ -0,0 +1,54 @@ +return { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = "make install_jsregexp", + dependencies = { + "rafamadriz/friendly-snippets", + }, + config = function() + require("luasnip").setup({ + update_events = "TextChanged,TextChangedI", + }) + + require("luasnip.loaders.from_vscode").lazy_load() + 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", + }, + }, +} diff --git a/.config/nvim/lua/plugins/mentor.lua b/.config/nvim/lua/plugins/mentor.lua new file mode 100644 index 0000000..04071c7 --- /dev/null +++ b/.config/nvim/lua/plugins/mentor.lua @@ -0,0 +1,9 @@ +return { + "cksidharthan/mentor.nvim", + opts = { + tips = { + "You can use shift+a to jump to end of line in insert mode.", + "Shift+p to paste in visual mode multiple times", + }, + }, +} diff --git a/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua new file mode 100644 index 0000000..107a0a0 --- /dev/null +++ b/.config/nvim/lua/plugins/neotest.lua @@ -0,0 +1,58 @@ +return { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", + "nvim-neotest/neotest-jest", + }, + keys = { + { + "tt", + function() + require("neotest").run.run() + end, + mode = "", + desc = "[T]est run under cursor", + }, + { + "ts", + function() + require("neotest").summary.toggle() + end, + mode = "", + desc = "[T]est [s]tatus", + }, + { + "tf", + function() + require("neotest").run.run(vim.fn.expand("%")) + end, + mode = "", + desc = "[T]est [f]ile", + }, + { + "tw", + function() + require("neotest").watch.watch() + end, + mode = "", + desc = "[T]est [w]atch under cursor", + }, + }, + config = function() + require("neotest").setup({ + discovery = { + enabled = false, + }, + adapters = { + require("neotest-jest")({ + cwd = function(path) + return vim.fn.getcwd() + end, + }), + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/snacks.lua b/.config/nvim/lua/plugins/snacks.lua index 2eea760..a0dee9c 100644 --- a/.config/nvim/lua/plugins/snacks.lua +++ b/.config/nvim/lua/plugins/snacks.lua @@ -10,7 +10,9 @@ return { input = { enabled = true }, notifier = { enabled = true, - timeout = 3000, + timeout = 10000, + width = { min = 40, max = 1000 }, + height = { min = 1, max = 1000 }, }, picker = { matcher = { diff --git a/.config/nvim/lua/plugins/typescript.lua b/.config/nvim/lua/plugins/typescript.lua deleted file mode 100644 index c3a85aa..0000000 --- a/.config/nvim/lua/plugins/typescript.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - -- "pmizio/typescript-tools.nvim", - -- dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, - -- opts = { - -- settings = { - -- jsx_close_tag = { - -- enable = true, - -- filetypes = { "javascriptreact", "typescriptreact" }, - -- }, - -- }, - -- }, -} diff --git a/.config/nvim/lua/snippets.lua b/.config/nvim/lua/snippets.lua new file mode 100644 index 0000000..10d2ab6 --- /dev/null +++ b/.config/nvim/lua/snippets.lua @@ -0,0 +1,57 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") +local extras = require("luasnip.extras") +local l = extras.lambda +local rep = extras.rep +local p = extras.partial +local m = extras.match +local n = extras.nonempty +local dl = extras.dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local conds = require("luasnip.extras.expand_conditions") +local postfix = require("luasnip.extras.postfix").postfix +local types = require("luasnip.util.types") +local parse = require("luasnip.util.parser").parse_snippet +local ms = ls.multi_snippet +local k = require("luasnip.nodes.key_indexer").new_key + +-- lua snippets +ls.add_snippets("lua", { + s( + "lreq", + fmt('local {name} = require("{mod}{rep}")', { + name = i(1, "name"), + rep = rep(1), + mod = i(2), + }) + ), +}) + +-- js/ts/sx snippets + +local import = s( + "im", + fmt("import {name} from '{module}';", { + module = i(1), + name = c(2, { i(nil), fmt("{{{}}}", { i(1) }) }), + }) +) + +ls.add_snippets("typescript", { + import, +}) + +ls.add_snippets("typescriptreact", { + import, +}) diff --git a/.config/sway/config b/.config/sway/config index c9dec55..8e97204 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -235,7 +235,7 @@ exec udiskie -t exec syncthing serve exec swaylock exec tuxedo-control-center --tray - +exec swaykbdd ### Idle configuration #