diff --git a/.zshrc b/.zshrc index b66bbca..1dd3327 100644 --- a/.zshrc +++ b/.zshrc @@ -115,11 +115,13 @@ source $ZSH/oh-my-zsh.sh alias python="python3" alias pip3="python3 -m pip" alias pip="python -m pip" -alias comp="cd ~/RustIsBestLang/src/bin && nvim" +alias comp="cd ~/CompetitiveProgramming/src/bin && nvim" +alias upgrade="yay --noconfirm --overwrite '*' && nix-channel --update && home-manager switch && brew upgrade && flatpak update -y && rustup update && pipx upgrade-all" alias backup="git add . && git commit -S -m 'backup' && git push" export LD_LIBRARY_PATH=/home/user/.local/lib/mojo:$LD_LIBRARY_PATH export PATH=/home/user/.modular/pkg/packages.modular.com_mojo/bin/:/home/user/.npm-packages/bin:/home/user/.cabal/bin:/home/user/.ghcup/bin:/home/linuxbrew/.linuxbrew/bin:/home/user/.cargo/bin:/home/user/.local/bin:/usr/local/cuda/bin:$PATH export PAGER=less +export EDITOR=nvim me () { md "$@" && cd "$@" diff --git a/dotback b/dotback index 1b18d07..ac6a388 100755 --- a/dotback +++ b/dotback @@ -27,3 +27,6 @@ cp $HOME/.config/home-manager . -r # NPM cp $HOME/.npmrc . + +# LF +cp $HOME/.config/lf . -r diff --git a/home-manager/home.nix b/home-manager/home.nix index af71f7f..157c320 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -23,19 +23,41 @@ # The home.packages option allows you to install Nix packages into your # environment. home.packages = [ - pkgs.mtr + # Install contour through Flatpak instead. + # pkgs.contour + + # Editor pkgs.neovim - pkgs.htop - pkgs.python312 - pkgs.pyright - pkgs.nodejs_22 - pkgs.pipx - pkgs.fx - pkgs.gdb pkgs.lua-language-server + pkgs.cmake-language-server + pkgs.helix + pkgs.zed-editor + + # Tools + pkgs.btop + pkgs.fx + pkgs.mtr + pkgs.htop + pkgs.gdb + + # Python + (pkgs.python312.withPackages (ps: with ps; [ + ])) + pkgs.pyright + pkgs.pipx + + # Node + pkgs.nodejs_22 + + # Waybar pkgs.waybar pkgs.waybar-mpris - pkgs.zed-editor + + # Misc + pkgs.lf # Terminal file manager + # pkgs.smassh # Typing test + pkgs.you-get # YouTube video downloader + pkgs.asciinema # Record terminal sessions # # It is sometimes useful to fine-tune packages, for example, by applying # # overrides. You can do that directly here, just don't forget the @@ -88,12 +110,4 @@ # Let Home Manager install and manage itself. programs.home-manager.enable = true; - - programs.helix = { - enable = true; - }; - - programs.btop = { - enable = true; - }; } diff --git a/lf/lfrc b/lf/lfrc new file mode 100644 index 0000000..979c4ab --- /dev/null +++ b/lf/lfrc @@ -0,0 +1,4 @@ +set icons +set number +set relativenumber +set hidden diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index b926272..b8b04f9 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -23,19 +23,19 @@ "eslint.nvim": { "branch": "main", "commit": "158f2289907d377018752fcfe0d61b746dc11767" }, "feline.nvim": { "branch": "master", "commit": "3587f57480b88e8009df7b36dc84e9c7ff8f2c49" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, - "fzf-lua": { "branch": "main", "commit": "fb058bd718aabe9a5abb3e9df3d5c1023d06cdae" }, + "fzf-lua": { "branch": "main", "commit": "769b6636af07ea4587e6c06067d8fe9fb0629390" }, "git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" }, - "gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" }, + "gitsigns.nvim": { "branch": "main", "commit": "f074844b60f9e151970fbcdbeb8a2cd52b6ef25a" }, "goto-preview": { "branch": "main", "commit": "1519ea3512828c944eed5b2bbb66a8f8deb92447" }, "haskell-vim": { "branch": "master", "commit": "f35d02204b4813d1dbe8b0e98cc39701a4b8e15e" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, "hlargs.nvim": { "branch": "main", "commit": "cc0d9ee75e5ffba730393049119361b9e3a5b1b6" }, "hop.nvim": { "branch": "master", "commit": "036462a345792279c58f2f6445756efab706f04a" }, "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, - "lazy.nvim": { "branch": "main", "commit": "9a374a0fb4d3ac42dac4a129d4bead7252473c77" }, - "lazydev.nvim": { "branch": "main", "commit": "02f1055a777264d4b65896051ec28d0f322f7932" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, "leetcode.nvim": { "branch": "master", "commit": "02fb2c855658ad6b60e43671f6b040c812181a1d" }, - "legendary.nvim": { "branch": "master", "commit": "0705f207ba79ee3c687fc77c451faeeb4828d5ad" }, + "legendary.nvim": { "branch": "master", "commit": "543bbbba4e7b54222362f312e1d2e3dac1eaae75" }, "listish.nvim": { "branch": "master", "commit": "3bc4bb02036f3802c6428c6232633d3192ac3604" }, "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, "lspkind.nvim": { "branch": "master", "commit": "67ec67c68f05ca41dab0d426c9e7c94ad86085f9" }, @@ -43,35 +43,35 @@ "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "markdown-toc.nvim": { "branch": "main", "commit": "75eabbdcb921f402b2e5b476e1a797a1004cdeaa" }, "marks.nvim": { "branch": "master", "commit": "74e8d01b2a2131b6e46354cffc553aa7f81bcf5b" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "58bc9119ca273c0ce5a66fad1927ef0f617bd81b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "melange-nvim": { "branch": "master", "commit": "800490ee87ce3e1b4afe751ff81f2864cb01937d" }, - "mini.nvim": { "branch": "main", "commit": "23669ab7abc2cd10f9a5166de07400bb34eaecda" }, + "mini.nvim": { "branch": "main", "commit": "e24ec1fcf885990fec1a993fe8304a033fd1806d" }, "modicator.nvim": { "branch": "main", "commit": "d1d327fd4bdfc3af4cfdf83b85c2eaefa71de7a8" }, - "neogit": { "branch": "master", "commit": "af1d8d88f426a4da63c913f3b81a37350dbe8d02" }, - "none-ls.nvim": { "branch": "main", "commit": "2cde745aadc2c36f6860a77a556494870675771a" }, + "neogit": { "branch": "master", "commit": "2b74a777b963dfdeeabfabf84d5ba611666adab4" }, + "none-ls.nvim": { "branch": "main", "commit": "a8594ef3dabb484adabc0ebbf5800be1b807c9e7" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, - "nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" }, + "nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "08bd34bf0ed79723f62764c7f9ca70516d461d0d" }, - "nvim-lspconfig": { "branch": "master", "commit": "e26da408cf955afa8e9ddbadd510e84ea8976cd7" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "194ec600488f7c7229668d0e80bd197f3a2b84ff" }, + "nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-neoclip.lua": { "branch": "main", "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-numbertoggle": { "branch": "main", "commit": "c5827153f8a955886f1b38eaea6998c067d2992f" }, "nvim-origami": { "branch": "main", "commit": "5d6b63bab5406e439937b04fc4ead201ba8dc88f" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-treesitter": { "branch": "master", "commit": "4e387dd47833c1bb8c8df6c3a7cab0d4c55583f3" }, + "nvim-treesitter": { "branch": "master", "commit": "2b4881286ad73c9ece7e5e4da130b2e4726c09fc" }, "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, - "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, - "oil.nvim": { "branch": "master", "commit": "9e5eb2fcd1dfee2ff30c89273ffff179e42034b9" }, + "nvim-web-devicons": { "branch": "master", "commit": "a2af6aa13a2ad3ad361d562a319a91bcd68c43a4" }, + "oil.nvim": { "branch": "master", "commit": "71c972fbd218723a3c15afcb70421f67340f5a6d" }, "outline.nvim": { "branch": "main", "commit": "2175b6da5b7b5be9de14fd3f54383a17f5e4609c" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "prettier.nvim": { "branch": "main", "commit": "d98e732cb73690b07c00c839c924be1d1d9ac5c2" }, - "render-markdown": { "branch": "main", "commit": "5e4e33102b784353998c83d57dbacea4db71d55b" }, + "render-markdown": { "branch": "main", "commit": "b75f681d675e21b5a09909997e9fffa6313c946e" }, "search.nvim": { "branch": "main", "commit": "27191f6c10a13c8018136b2490342d35960ed0ab" }, "sg.nvim": { "branch": "master", "commit": "8bdd4d19da2268072708d5fe18fda9c23e16509d" }, "smart-open.nvim": { "branch": "0.2.x", "commit": "87626ee8748b9bba22093adec7bb58c63e7214f0" }, @@ -84,9 +84,9 @@ "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" }, - "todo-comments.nvim": { "branch": "main", "commit": "96fee098a90e7c09c9811aa7df71d773ba8b9b53" }, - "trouble.nvim": { "branch": "main", "commit": "ad8ef38666834e9e438f84bd446657445bc2a71e" }, - "twilight.nvim": { "branch": "main", "commit": "38dc017474ef05605ca14a2577e01e09f0db7133" }, + "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, + "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, "vim-cursorword": { "branch": "master", "commit": "34852083276c1fd9ff4cccaf052111e7d5a2472e" }, "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, "vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" }, @@ -94,6 +94,6 @@ "vim-prosession": { "branch": "master", "commit": "4b8323d4e9b74afe9132a34b2d7ea6cfa9461550" }, "vim-visual-multi": { "branch": "master", "commit": "38b0e8d94a5499ccc17d6159763d32c79f53417b" }, "vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" }, - "vim-wakatime": { "branch": "master", "commit": "d72aac70fcee172413f89621b65b5383bd845e4b" }, - "which-key.nvim": { "branch": "main", "commit": "6e61b0904e9c038b6c511c43591ae2d811b4975e" } + "vim-wakatime": { "branch": "master", "commit": "53bba6bb8342de9cbdafc82142a9b5e82008d858" }, + "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" } } diff --git a/nvim/lua/config.lua b/nvim/lua/config.lua index e834677..7a31928 100644 --- a/nvim/lua/config.lua +++ b/nvim/lua/config.lua @@ -46,14 +46,14 @@ vim.filetype.add({ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) @@ -92,9 +92,9 @@ local plugins = { -- 'folke/neodev.nvim', }, config = function(_, servers) - for server, opts in pairs(servers) do - require('lspconfig')[server].setup(opts) - end + for server, opts in pairs(servers) do + require('lspconfig')[server].setup(opts) + end end, }, { @@ -119,10 +119,10 @@ local plugins = { }, init = function() vim.g.barbar_auto_setup = false end, opts = { - -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: - animation = false, - -- insert_at_start = true, - -- …etc. + -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: + animation = false, + -- insert_at_start = true, + -- …etc. }, version = '^1.0.0', -- optional: only update when a new 1.x version is released }, @@ -166,31 +166,31 @@ local plugins = { }, }, { - "arielherself/arshamiser.nvim", -- status bar + "arielherself/arshamiser.nvim", -- status bar branch = "dev", - dependencies = { - "arsham/arshlib.nvim", - "famiu/feline.nvim", - "rebelot/heirline.nvim", - "nvim-tree/nvim-web-devicons", - "lewis6991/gitsigns.nvim", - "nanotee/sqls.nvim", - "arsham/listish.nvim", - }, - config = function() + dependencies = { + "arsham/arshlib.nvim", + "famiu/feline.nvim", + "rebelot/heirline.nvim", + "nvim-tree/nvim-web-devicons", + "lewis6991/gitsigns.nvim", + "nanotee/sqls.nvim", + "arsham/listish.nvim", + }, + config = function() require('gitsigns').setup() - -- ignore any parts you don't want to use - vim.cmd.colorscheme("arshamiser_dark") - -- require("arshamiser.feliniser") - -- or: - require("arshamiser.heirliniser") + -- ignore any parts you don't want to use + vim.cmd.colorscheme("arshamiser_dark") + -- require("arshamiser.feliniser") + -- or: + require("arshamiser.heirliniser") - _G.custom_foldtext = require("arshamiser.folding").foldtext - vim.opt.foldtext = "v:lua.custom_foldtext()" - -- if you want to draw a tabline: - -- vim.api.nvim_set_option("tabline", [[%{%v:lua.require("arshamiser.tabline").draw()%}]]) - end, + _G.custom_foldtext = require("arshamiser.folding").foldtext + vim.opt.foldtext = "v:lua.custom_foldtext()" + -- if you want to draw a tabline: + -- vim.api.nvim_set_option("tabline", [[%{%v:lua.require("arshamiser.tabline").draw()%}]]) + end, }, { 'numToStr/Comment.nvim', -- `gc` for commenting @@ -238,20 +238,20 @@ local plugins = { 'mawkler/modicator.nvim' -- highlight current line number }, { - "ecthelionvi/NeoColumn.nvim", -- highlight overflow columns? - opts = {} + "ecthelionvi/NeoColumn.nvim", -- highlight overflow columns? + opts = {} }, { - "utilyre/barbecue.nvim", -- LSP winbar - name = "barbecue", - version = "*", - dependencies = { - "SmiteshP/nvim-navic", - "nvim-tree/nvim-web-devicons", -- optional dependency - }, - opts = { - -- configurations go here - }, + "utilyre/barbecue.nvim", -- LSP winbar + name = "barbecue", + version = "*", + dependencies = { + "SmiteshP/nvim-navic", + "nvim-tree/nvim-web-devicons", -- optional dependency + }, + opts = { + -- configurations go here + }, }, { 'akinsho/git-conflict.nvim', -- `GitConflictChooseOurs` @@ -259,25 +259,25 @@ local plugins = { config = true, }, { - 'mrjones2014/legendary.nvim', - -- since legendary.nvim handles all your keymaps/commands, - -- its recommended to load legendary.nvim before other plugins - priority = 10000, - lazy = false, - -- sqlite is only needed if you want to use frecency sorting - -- dependencies = { 'kkharji/sqlite.lua' } + 'mrjones2014/legendary.nvim', + -- since legendary.nvim handles all your keymaps/commands, + -- its recommended to load legendary.nvim before other plugins + priority = 10000, + lazy = false, + -- sqlite is only needed if you want to use frecency sorting + -- dependencies = { 'kkharji/sqlite.lua' } }, { - 'stevearc/dressing.nvim', -- better UI - opts = {}, + 'stevearc/dressing.nvim', -- better UI + opts = {}, }, { - "folke/twilight.nvim", -- Focus on parts that's being edited - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } + "folke/twilight.nvim", -- Focus on parts that's being edited + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } }, { "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} }, { 'arielherself/vim-cursorword' }, @@ -302,26 +302,26 @@ local plugins = { end }, { - "folke/trouble.nvim", -- TroubleToggle - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, + "folke/trouble.nvim", -- TroubleToggle + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, }, { "arielherself/melange-nvim" }, { 'hrsh7th/vim-vsnip' }, { - "NeogitOrg/neogit", -- - dependencies = { - "sindrets/diffview.nvim", -- optional - Diff integration + "NeogitOrg/neogit", -- + dependencies = { + "sindrets/diffview.nvim", -- optional - Diff integration - -- Only one of these is needed, not both. - "nvim-telescope/telescope.nvim", -- optional - "ibhagwan/fzf-lua", -- optional - }, - config = true + -- Only one of these is needed, not both. + "nvim-telescope/telescope.nvim", -- optional + "ibhagwan/fzf-lua", -- optional + }, + config = true }, -- { 'Exafunction/codeium.vim' }, { @@ -339,34 +339,34 @@ local plugins = { }, { 'debugloop/telescope-undo.nvim' }, { - "folke/lazydev.nvim", -- Autocompletion when editing Neovim configs or developing plugins - ft = "lua", -- only load on lua files - opts = { - library = { - -- lazypath .. "/luvit-meta/library", -- see below - -- You can also add plugins you always want to have loaded. - -- Useful if the plugin has globals or types you want to use - -- vim.env.LAZY .. "/LazyVim", -- see below + "folke/lazydev.nvim", -- Autocompletion when editing Neovim configs or developing plugins + ft = "lua", -- only load on lua files + opts = { + library = { + -- lazypath .. "/luvit-meta/library", -- see below + -- You can also add plugins you always want to have loaded. + -- Useful if the plugin has globals or types you want to use + -- vim.env.LAZY .. "/LazyVim", -- see below + }, }, - }, }, { "Bilal2453/luvit-meta", lazy = true }, { - "AckslD/nvim-neoclip.lua", -- `p` + "AckslD/nvim-neoclip.lua", -- `p` }, { - "danielfalk/smart-open.nvim", -- sort file search results by frequency - branch = "0.2.x", - config = function() - require("telescope").load_extension("smart_open") - end, - dependencies = { - "kkharji/sqlite.lua", - -- Only required if using match_algorithm fzf - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - -- Optional. If installed, native fzy will be used when match_algorithm is fzy - { "nvim-telescope/telescope-fzy-native.nvim" }, - }, + "danielfalk/smart-open.nvim", -- sort file search results by frequency + branch = "0.2.x", + config = function() + require("telescope").load_extension("smart_open") + end, + dependencies = { + "kkharji/sqlite.lua", + -- Only required if using match_algorithm fzf + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + -- Optional. If installed, native fzy will be used when match_algorithm is fzy + { "nvim-telescope/telescope-fzy-native.nvim" }, + }, }, { "chrisgrieser/nvim-origami", -- Fold keymap @@ -408,25 +408,25 @@ local plugins = { end, }, { - 'stevearc/oil.nvim', - opts = {}, - -- Optional dependencies - dependencies = { "nvim-tree/nvim-web-devicons" }, + 'stevearc/oil.nvim', + opts = {}, + -- Optional dependencies + dependencies = { "nvim-tree/nvim-web-devicons" }, }, { - "aznhe21/actions-preview.nvim", - config = function() - vim.keymap.set({ "v", "n" }, "a", require("actions-preview").code_actions) - end, + "aznhe21/actions-preview.nvim", + config = function() + vim.keymap.set({ "v", "n" }, "a", require("actions-preview").code_actions) + end, }, { "neovimhaskell/haskell-vim" }, { - "hedyhli/markdown-toc.nvim", - ft = "markdown", -- Lazy load on markdown filetype - cmd = { "Mtoc" }, -- Or, lazy load on "Mtoc" command - opts = { - -- Your configuration here (optional) - }, + "hedyhli/markdown-toc.nvim", + ft = "markdown", -- Lazy load on markdown filetype + cmd = { "Mtoc" }, -- Or, lazy load on "Mtoc" command + opts = { + -- Your configuration here (optional) + }, }, { "iamcco/markdown-preview.nvim", @@ -540,31 +540,33 @@ config.setup({ -- import nvim-cmp plugin safely local cmp_status, cmp = pcall(require, "cmp") if not cmp_status then - return + return end -- import luasnip plugin safely local luasnip_status, luasnip = pcall(require, "luasnip") if not luasnip_status then - return + return end vim.opt.completeopt = "menu,menuone,noselect" local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +local is_empty_line = function() + unpack = unpack or table.unpack + local line, _ = unpack(vim.api.nvim_win_get_cursor(0)) + return vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:match("%S") == nil end local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end -local ELLIPSIS_CHAR = '…' -local MAX_LABEL_WIDTH = 20 -local MIN_LABEL_WIDTH = 20 - cmp.setup { snippet = { expand = function(args) @@ -574,7 +576,11 @@ cmp.setup { mapping = { [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.confirm({ select = true }) + if not is_empty_line() then + cmp.confirm({ select = true }) + else + fallback() + end elseif luasnip_status and luasnip.expand_or_jumpable() then luasnip.expand_or_jump() elseif has_words_before() then @@ -636,14 +642,14 @@ lspconfig.tsserver.setup { } lspconfig.rust_analyzer.setup { capabilities = capabilities, - -- Server-specific settings. See `:help lspconfig-setup` - settings = { - ['rust-analyzer'] = { - checkOnSave = { - command = 'clippy', - } + -- Server-specific settings. See `:help lspconfig-setup` + settings = { + ['rust-analyzer'] = { + checkOnSave = { + command = 'clippy', + } + }, }, - }, } lspconfig.hls.setup {} lspconfig.lua_ls.setup { @@ -660,7 +666,7 @@ lspconfig.mojo.setup {} capabilities.workspace = { didChangeWatchedFiles = { - dynamicRegistration = true, + dynamicRegistration = true, }, } require("lspconfig").markdown_oxide.setup({ @@ -688,29 +694,29 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- Use LspAttach autocommand to only map the following keys -- after the language server attaches to the current buffer vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - -- Enable completion triggered by - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local opts = { buffer = ev.buf } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, opts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - end, + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + end, }) require("lsp_signature").setup({ @@ -767,24 +773,24 @@ vim.api.nvim_create_user_command('SearchInCurrentFile', function() end, {}) vim.api.nvim_create_user_command('PopupSaveas', function() - vim.ui.input({ prompt = 'Save As: ' }, function(input) - if input ~= nil then - if vim.fn.filereadable(input) == 1 then - local choice = vim.fn.input('File exists. Overwrite? ([y]/n): ') - if choice ~= 'n' then - vim.cmd('saveas! ' .. input) - print('File overwritten: ' .. input) + vim.ui.input({ prompt = 'Save As: ' }, function(input) + if input ~= nil then + if vim.fn.filereadable(input) == 1 then + local choice = vim.fn.input('File exists. Overwrite? ([y]/n): ') + if choice ~= 'n' then + vim.cmd('saveas! ' .. input) + print('File overwritten: ' .. input) + else + print('Cancelled') + end + else + vim.cmd('saveas ' .. input) + print('File saved as: ' .. input) + end else - print('Cancelled') + print('Save As cancelled') end - else - vim.cmd('saveas ' .. input) - print('File saved as: ' .. input) - end - else - print('Save As cancelled') - end - end) + end) end, {}) require("nvim-treesitter.configs").setup { @@ -803,88 +809,88 @@ require("nvim-treesitter.configs").setup { }, textobjects = { select = { - enable = true, - lookahead = false, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - -- You can optionally set descriptions to the mappings (used in the desc parameter of - -- nvim_buf_set_keymap) which plugins like which-key display - ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" }, - -- You can also use captures from other query groups like `locals.scm` - ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" }, - }, - -- You can choose the select mode (default is charwise 'v') - -- - -- Can also be a function which gets passed a table with the keys - -- * query_string: eg '@function.inner' - -- * method: eg 'v' or 'o' - -- and should return the mode ('v', 'V', or '') or a table - -- mapping query_strings to modes. - selection_modes = { - ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise - ['@class.outer'] = '', -- blockwise - }, - -- If you set this to `true` (default is `false`) then any textobject is - -- extended to include preceding or succeeding whitespace. Succeeding - -- whitespace has priority in order to act similarly to eg the built-in - -- `ap`. - -- - -- Can also be a function which gets passed a table with the keys - -- * query_string: eg '@function.inner' - -- * selection_mode: eg 'v' - -- and should return true or false - include_surrounding_whitespace = false, + enable = true, + lookahead = false, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + -- You can optionally set descriptions to the mappings (used in the desc parameter of + -- nvim_buf_set_keymap) which plugins like which-key display + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" }, + -- You can also use captures from other query groups like `locals.scm` + ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" }, + }, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '') or a table + -- mapping query_strings to modes. + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- blockwise + }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true or false + include_surrounding_whitespace = false, }, swap = { - enable = true, - swap_next = { - ["]]"] = "@parameter.inner", - }, - swap_previous = { - ["[["] = "@parameter.inner", - }, + enable = true, + swap_next = { + ["]]"] = "@parameter.inner", + }, + swap_previous = { + ["[["] = "@parameter.inner", + }, }, move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]c"] = { query = "@class.outer", desc = "Next class start" }, - -- - -- You can use regex matching (i.e. lua pattern) and/or pass a list in a "query" key to group multiple queires. - ["]o"] = "@loop.*", - -- ["]o"] = { query = { "@loop.inner", "@loop.outer" } } - -- - -- You can pass a query group to use query from `queries//.scm file in your runtime path. - -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. - ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, - ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]C"] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[c"] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[C"] = "@class.outer", - }, - -- Below will go to either the start or the end, whichever is closer. - -- Use if you want more granular movements - -- Make it even more gradual by adding multiple queries and regex. - goto_next = { - ["]d"] = "@conditional.outer", - }, - goto_previous = { - ["[d"] = "@conditional.outer", - } + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]c"] = { query = "@class.outer", desc = "Next class start" }, + -- + -- You can use regex matching (i.e. lua pattern) and/or pass a list in a "query" key to group multiple queires. + ["]o"] = "@loop.*", + -- ["]o"] = { query = { "@loop.inner", "@loop.outer" } } + -- + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]C"] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[c"] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[C"] = "@class.outer", + }, + -- Below will go to either the start or the end, whichever is closer. + -- Use if you want more granular movements + -- Make it even more gradual by adding multiple queries and regex. + goto_next = { + ["]d"] = "@conditional.outer", + }, + goto_previous = { + ["[d"] = "@conditional.outer", + } }, }, endwise = { enable = true, }, @@ -921,8 +927,8 @@ cmp.setup { format = lspkind.cmp_format({ mode = 'symbol_text', -- show only symbol annotations maxwidth = 30, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - -- can also be a function to dynamically calculate max width such as - -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, + -- can also be a function to dynamically calculate max width such as + -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, ellipsis_char = '…', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) show_labelDetails = true, -- show labelDetails in menu. Disabled by default @@ -955,44 +961,44 @@ local eslint = require("eslint") null_ls.setup() eslint.setup({ - bin = 'eslint', -- or `eslint_d` - code_actions = { - enable = true, - apply_on_save = { - enable = true, - types = { "directive", "problem", "suggestion", "layout" }, + bin = 'eslint', -- or `eslint_d` + code_actions = { + enable = true, + apply_on_save = { + enable = true, + types = { "directive", "problem", "suggestion", "layout" }, + }, + disable_rule_comment = { + enable = true, + location = "separate_line", -- or `same_line` + }, }, - disable_rule_comment = { - enable = true, - location = "separate_line", -- or `same_line` + diagnostics = { + enable = true, + report_unused_disable_directives = false, + run_on = "type", -- or `save` }, - }, - diagnostics = { - enable = true, - report_unused_disable_directives = false, - run_on = "type", -- or `save` - }, }) local prettier = require("prettier") prettier.setup({ - bin = 'prettier', -- or `'prettierd'` (v0.23.3+) - filetypes = { - "css", - "graphql", - "html", - "javascript", - "javascriptreact", - "json", - "less", - "markdown", - "scss", - "typescript", - "typescriptreact", - "yaml", - "vue", - }, + bin = 'prettier', -- or `'prettierd'` (v0.23.3+) + filetypes = { + "css", + "graphql", + "html", + "javascript", + "javascriptreact", + "json", + "less", + "markdown", + "scss", + "typescript", + "typescriptreact", + "yaml", + "vue", + }, }) require("outline").setup() @@ -1000,7 +1006,7 @@ require("outline").setup() require("todo-comments").setup() lspconfig.volar.setup{ - filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'} + filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'} } local map = vim.api.nvim_set_keymap @@ -1090,24 +1096,24 @@ vim.api.nvim_create_autocmd("LspAttach", { require('neoclip').setup {} require("oil").setup{ - columns = { - "icon", - "permissions", - "size", - "mtime", - }, - win_options = { - signcolumn = "yes", - }, - view_options = { - show_hidden = true, - }, - constrain_cursor = "editable", - keymaps = { - [""] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" }, - [""] = { "actions.select", opts = { horizontal = true }, desc = "Open the entry in a horizontal split" }, - [""] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" }, - }, + columns = { + "icon", + "permissions", + "size", + "mtime", + }, + win_options = { + signcolumn = "yes", + }, + view_options = { + show_hidden = true, + }, + constrain_cursor = "editable", + keymaps = { + [""] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" }, + [""] = { "actions.select", opts = { horizontal = true }, desc = "Open the entry in a horizontal split" }, + [""] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" }, + }, } -- refresh codelens on TextChanged and InsertLeave as well diff --git a/nvim/lua/snippets/init.lua b/nvim/lua/snippets/init.lua index fd688da..bfd6f4f 100644 --- a/nvim/lua/snippets/init.lua +++ b/nvim/lua/snippets/init.lua @@ -288,3 +288,15 @@ ls.add_snippets(nil, { } }) +local lca = require('snippets.lca') +ls.add_snippets(nil, { + cpp = { + snip({ + trig = 'lca', + namr = 'lca', + dscr = 'LCA', + },{ + text(lines(lca)) + }) + } +}) diff --git a/nvim/lua/snippets/lca.lua b/nvim/lua/snippets/lca.lua new file mode 100644 index 0000000..b880e80 --- /dev/null +++ b/nvim/lua/snippets/lca.lua @@ -0,0 +1,50 @@ +return [=[ +struct LCA { + vector depth; + vector> pa; + LCA(const vector>& g, int root = 1) { + int n = g.size() - 1; + int m = 32 - __builtin_clz(n); + depth.resize(n + 1); + pa.resize(n + 1, vector(m, -1)); + function dfs = [&](int x, int fa) { + pa[x][0] = fa; + for (int y: g[x]) { + if (y != fa) { + depth[y] = depth[x] + 1; + dfs(y, x); + } + } + }; + dfs(root, 0); + + for (int i = 0; i < m - 1; i++) + for (int x = 1; x <= n; x++) + if (int p = pa[x][i]; p != -1) + pa[x][i + 1] = pa[p][i]; + } + + int get_kth_ancestor(int node, int k) { + for (; k; k &= k - 1) + node = pa[node][__builtin_ctz(k)]; + return node; + } + + int query(int x, int y) { + if (depth[x] > depth[y]) + swap(x, y); + y = get_kth_ancestor(y, depth[y] - depth[x]); + if (y == x) + return x; + for (int i = pa[x].size() - 1; i >= 0; i--) { + int px = pa[x][i], py = pa[y][i]; + if (px != py) { + x = px; + y = py; + } + } + return pa[x][0]; + } +}; + +]=] diff --git a/waybar/config.jsonc b/waybar/config.jsonc index d8e2a64..50183cd 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -187,7 +187,7 @@ }, "custom/waybar-mpris": { "return-type": "json", - "exec": "waybar-mpris --position --autofocus --order 'SYMBOL:TITLE:ARTIST:POSITION'", + "exec": "waybar-mpris --position --autofocus --order 'SYMBOL:POSITION:TITLE:ARTIST'", "on-click": "waybar-mpris --send toggle", // This option will switch between players on right click. "on-click-right": "waybar-mpris --send player-next", @@ -198,6 +198,7 @@ // "on-scroll-up": "waybar-mpris --send next", // "on-scroll-down": "waybar-mpris --send prev", "escape": true, + "max-length": 50, }, "custom/clock": { "exec": "LC_TIME=en_US.UTF8 date +'%-m-%-d[%a] %H:%M'",