diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-06-24 16:34:51 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-06-24 16:34:51 +0800 |
| commit | 2a1645ae9593114514a7f28fa6d9109d1820375d (patch) | |
| tree | bab2ac0a019ca9af961a04b2a58f0bac3d49bdeb | |
| parent | fdb53f590cef5499b14322d22fee47722b135626 (diff) | |
Update
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | vim/init/basic.vim | 2 | ||||
| -rw-r--r-- | vim/init/keymaps.vim | 4 | ||||
| -rw-r--r-- | vim/lazy/lazy.lua | 424 | ||||
| -rw-r--r-- | vim/lazy/plugin/telescope.lua | 105 | ||||
| -rw-r--r-- | vim/lazy/plugin/treesitter.lua | 231 | ||||
| -rw-r--r-- | vim/nvim/init.vim | 44 | ||||
| -rw-r--r-- | vim/nvim/lazy.lua | 39 | ||||
| -rw-r--r-- | vim/nvim/lua/chadrc.lua | 47 | ||||
| -rw-r--r-- | vim/nvim/lua/configs/conform.lua | 15 | ||||
| -rw-r--r-- | vim/nvim/lua/configs/lazy.lua | 47 | ||||
| -rw-r--r-- | vim/nvim/lua/configs/lspconfig.lua | 23 | ||||
| -rw-r--r-- | vim/nvim/lua/configs/telescope.lua | 48 | ||||
| -rw-r--r-- | vim/nvim/lua/configs/treesitter.lua | 62 | ||||
| -rw-r--r-- | vim/nvim/lua/mappings.lua | 170 | ||||
| -rw-r--r-- | vim/nvim/lua/options.lua | 20 | ||||
| -rw-r--r-- | vim/nvim/lua/plugins/init.lua | 218 |
17 files changed, 738 insertions, 762 deletions
| @@ -1,2 +1,3 @@ | |||
| 1 | private/* | 1 | private/* |
| 2 | tokens/* | 2 | tokens/* |
| 3 | lazy-lock.json | ||
diff --git a/vim/init/basic.vim b/vim/init/basic.vim index eb895e2..d90bfc0 100644 --- a/vim/init/basic.vim +++ b/vim/init/basic.vim | |||
| @@ -43,7 +43,7 @@ filetype plugin indent on | |||
| 43 | " VISUAL | 43 | " VISUAL |
| 44 | "---------------------------------------------------------------------- | 44 | "---------------------------------------------------------------------- |
| 45 | 45 | ||
| 46 | colorscheme desert " I like desert! | 46 | " colorscheme desert " I like desert! |
| 47 | " In most of the cases, it is overrides by lightline.vim | 47 | " In most of the cases, it is overrides by lightline.vim |
| 48 | set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c | 48 | set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c |
| 49 | set showmatch " Show pairing brackets | 49 | set showmatch " Show pairing brackets |
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index c57a57c..9d1003b 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
| @@ -77,8 +77,10 @@ vnoremap <leader>, :terminal<CR> | |||
| 77 | " Toggle paste mode on and off | 77 | " Toggle paste mode on and off |
| 78 | map <leader>pp :setlocal paste!<cr> | 78 | map <leader>pp :setlocal paste!<cr> |
| 79 | 79 | ||
| 80 | " Switch CDW to root git directory | ||
| 81 | nnoremap <Leader>cd :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> | ||
| 80 | " Switch CWD to the directory of the open buffer | 82 | " Switch CWD to the directory of the open buffer |
| 81 | map <leader>cd :cd %:p:h<cr>:pwd<cr> | 83 | map <leader>cD :cd %:p:h<cr>:pwd<cr> |
| 82 | 84 | ||
| 83 | " Move one line up and down | 85 | " Move one line up and down |
| 84 | nnoremap <C-j> ddp | 86 | nnoremap <C-j> ddp |
diff --git a/vim/lazy/lazy.lua b/vim/lazy/lazy.lua deleted file mode 100644 index 4aef220..0000000 --- a/vim/lazy/lazy.lua +++ /dev/null | |||
| @@ -1,424 +0,0 @@ | |||
| 1 | --[[ | ||
| 2 | |||
| 3 | From kickstarter | ||
| 4 | |||
| 5 | TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. | ||
| 6 | |||
| 7 | If you don't know anything about Lua, I recommend taking some time to read through | ||
| 8 | a guide. One possible example which will only take 10-15 minutes: | ||
| 9 | - https://learnxinyminutes.com/docs/lua/ | ||
| 10 | |||
| 11 | After understanding a bit more about Lua, you can use `:help lua-guide` as a | ||
| 12 | reference for how Neovim integrates Lua. | ||
| 13 | - :help lua-guide | ||
| 14 | - (or HTML version): https://neovim.io/doc/user/lua-guide.html | ||
| 15 | |||
| 16 | MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation, | ||
| 17 | which is very useful when you're not exactly sure of what you're looking for. | ||
| 18 | --]] | ||
| 19 | |||
| 20 | -- Install package manager | ||
| 21 | -- https://github.com/folke/lazy.nvim | ||
| 22 | -- `:help lazy.nvim.txt` for more info | ||
| 23 | local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' | ||
| 24 | if not vim.loop.fs_stat(lazypath) then | ||
| 25 | vim.fn.system { | ||
| 26 | 'git', | ||
| 27 | 'clone', | ||
| 28 | '--filter=blob:none', | ||
| 29 | 'https://github.com/folke/lazy.nvim.git', | ||
| 30 | '--branch=stable', -- latest stable release | ||
| 31 | lazypath, | ||
| 32 | } | ||
| 33 | end | ||
| 34 | vim.opt.runtimepath:prepend(lazypath) | ||
| 35 | |||
| 36 | -- NOTE: Here is where you install your plugins. | ||
| 37 | -- You can configure plugins using the `config` key. | ||
| 38 | -- | ||
| 39 | -- You can also configure plugins after the setup call, | ||
| 40 | -- as they will be available in your neovim runtime. | ||
| 41 | require('lazy').setup({ | ||
| 42 | -- NOTE: First, some plugins that don't require any configuration | ||
| 43 | -- Git related plugins | ||
| 44 | 'tpope/vim-fugitive', | ||
| 45 | -- 'tpope/vim-rhubarb', | ||
| 46 | |||
| 47 | -- Detect tabstop and shiftwidth automatically | ||
| 48 | 'tpope/vim-sleuth', | ||
| 49 | |||
| 50 | -- Use sudo in command mode | ||
| 51 | 'lambdalisue/suda.vim', | ||
| 52 | |||
| 53 | -- For surrounding | ||
| 54 | 'tpope/vim-surround', | ||
| 55 | |||
| 56 | |||
| 57 | -- From vim plugin | ||
| 58 | 'junegunn/goyo.vim', | ||
| 59 | 'itchyny/lightline.vim', | ||
| 60 | 'preservim/nerdtree', | ||
| 61 | |||
| 62 | -- gitsigns.nvim: Adds git related signs to the gutter, as well as utilities for managing changes | ||
| 63 | { | ||
| 64 | 'lewis6991/gitsigns.nvim', | ||
| 65 | opts = { | ||
| 66 | -- See `:help gitsigns.txt` | ||
| 67 | signs = { | ||
| 68 | add = { text = '+' }, | ||
| 69 | change = { text = '~' }, | ||
| 70 | delete = { text = '_' }, | ||
| 71 | topdelete = { text = '‾' }, | ||
| 72 | changedelete = { text = '~' }, | ||
| 73 | }, | ||
| 74 | on_attach = function(bufnr) | ||
| 75 | vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, | ||
| 76 | { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) | ||
| 77 | vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) | ||
| 78 | vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) | ||
| 79 | vim.keymap.set('n', '<leader>hd', require('gitsigns').diffthis, { buffer = bufnr, desc = '[h]unk [d]iff' }) | ||
| 80 | vim.keymap.set('n', '<leader>hD', function() require('gitsigns').diffthis('~') end, | ||
| 81 | { buffer = bufnr, desc = '[h]unk [d]iff for ~' }) | ||
| 82 | vim.keymap.set('v', 'hr', ":Gitsigns reset_hunk<CR>", { buffer = bufnr, desc = '[h]unk [r]eset' }) | ||
| 83 | end, | ||
| 84 | }, | ||
| 85 | }, | ||
| 86 | |||
| 87 | -- onedark: colorscheme | ||
| 88 | { | ||
| 89 | -- onedark.nvim: Theme inspired by Atom | ||
| 90 | 'navarasu/onedark.nvim', | ||
| 91 | priority = 1000, | ||
| 92 | config = function() | ||
| 93 | vim.cmd.colorscheme 'onedark' | ||
| 94 | -- vim.cmd('source ~/.vim/vim-init/init/init-basic.vim') | ||
| 95 | end, | ||
| 96 | }, | ||
| 97 | |||
| 98 | -- hop.nvim: For quick jump | ||
| 99 | { | ||
| 100 | 'smoka7/hop.nvim', | ||
| 101 | version = "*", | ||
| 102 | opts = { | ||
| 103 | keys = 'etovxqpdygfblzhckisuran' | ||
| 104 | } | ||
| 105 | }, | ||
| 106 | |||
| 107 | -- which-key.nvim: Useful plugin to show you pending keybinds. | ||
| 108 | { | ||
| 109 | 'folke/which-key.nvim', | ||
| 110 | opts = { | ||
| 111 | plugins = { | ||
| 112 | spelling = { | ||
| 113 | enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions | ||
| 114 | suggestions = 20, -- how many suggestions should be shown in the list? | ||
| 115 | }, | ||
| 116 | } | ||
| 117 | } | ||
| 118 | }, | ||
| 119 | |||
| 120 | -- obsidian.nvim: For obsidian | ||
| 121 | { | ||
| 122 | "epwalsh/obsidian.nvim", | ||
| 123 | version = "*", -- recommended, use latest release instead of latest commit | ||
| 124 | lazy = true, | ||
| 125 | ft = "markdown", | ||
| 126 | -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: | ||
| 127 | -- event = { | ||
| 128 | -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. | ||
| 129 | -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" | ||
| 130 | -- "BufReadPre path/to/my-vault/**.md", | ||
| 131 | -- "BufNewFile path/to/my-vault/**.md", | ||
| 132 | -- }, | ||
| 133 | dependencies = { | ||
| 134 | -- Required. | ||
| 135 | "nvim-lua/plenary.nvim", | ||
| 136 | |||
| 137 | -- see below for full list of optional dependencies 👇 | ||
| 138 | }, | ||
| 139 | opts = { | ||
| 140 | workspaces = { | ||
| 141 | { | ||
| 142 | name = "log", | ||
| 143 | path = "~/log", | ||
| 144 | }, | ||
| 145 | }, | ||
| 146 | completion = { | ||
| 147 | -- Set to false to disable completion. | ||
| 148 | nvim_cmp = true, | ||
| 149 | -- Trigger completion at 2 chars. | ||
| 150 | min_chars = 2, | ||
| 151 | }, | ||
| 152 | mapping = { | ||
| 153 | -- Toggle check-boxes. | ||
| 154 | ["<leader>oc"] = { | ||
| 155 | action = function() | ||
| 156 | return require("obsidian").util.toggle_checkbox() | ||
| 157 | end, | ||
| 158 | opts = { buffer = true }, | ||
| 159 | }, | ||
| 160 | -- Smart action depending on context, either follow link or toggle checkbox. | ||
| 161 | ["<cr>"] = { | ||
| 162 | action = function() | ||
| 163 | return require("obsidian").util.smart_action() | ||
| 164 | end, | ||
| 165 | opts = { buffer = true, expr = true }, | ||
| 166 | } | ||
| 167 | }, | ||
| 168 | -- see below for full list of options 👇 | ||
| 169 | note_id_func = function(title) | ||
| 170 | return title | ||
| 171 | -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. | ||
| 172 | -- In this case a note with the title 'My new note' will be given an ID that looks | ||
| 173 | -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' | ||
| 174 | -- local suffix = "" | ||
| 175 | -- title = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() | ||
| 176 | -- if title ~= nil and title ~= "" then | ||
| 177 | -- -- If title is given, transform it into valid file name. | ||
| 178 | -- suffix = "-" .. title | ||
| 179 | -- else | ||
| 180 | -- -- If title is nil, just add 4 random uppercase letters to the suffix. | ||
| 181 | -- for _ = 1, 4 do | ||
| 182 | -- suffix = suffix .. string.char(math.random(65, 90)) | ||
| 183 | -- end | ||
| 184 | -- suffix = "-" .. title | ||
| 185 | -- end | ||
| 186 | -- return tostring(os.time()) .. suffix | ||
| 187 | end, | ||
| 188 | }, | ||
| 189 | }, | ||
| 190 | |||
| 191 | -- markdown-preview: Install without yarn or npm | ||
| 192 | { | ||
| 193 | "iamcco/markdown-preview.nvim", | ||
| 194 | cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, | ||
| 195 | ft = { "markdown" }, | ||
| 196 | build = function() vim.fn["mkdp#util#install"]() end, | ||
| 197 | }, | ||
| 198 | |||
| 199 | -- vim-beancount: For beancount | ||
| 200 | { | ||
| 201 | 'nathangrigg/vim-beancount', | ||
| 202 | ft = { "beancount" }, | ||
| 203 | }, | ||
| 204 | |||
| 205 | -- NOTE: This is where your plugins related to LSP can be installed. | ||
| 206 | -- The configuration is done below. Search for lspconfig to find it below. | ||
| 207 | { | ||
| 208 | -- LSP Configuration & Plugins | ||
| 209 | 'neovim/nvim-lspconfig', | ||
| 210 | dependencies = { | ||
| 211 | -- Automatically install LSPs to stdpath for neovim | ||
| 212 | { 'williamboman/mason.nvim', config = true }, | ||
| 213 | 'williamboman/mason-lspconfig.nvim', | ||
| 214 | |||
| 215 | -- Useful status updates for LSP | ||
| 216 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` | ||
| 217 | { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, | ||
| 218 | |||
| 219 | -- Additional lua configuration, makes nvim stuff amazing! | ||
| 220 | 'folke/neodev.nvim', | ||
| 221 | }, | ||
| 222 | }, | ||
| 223 | |||
| 224 | { | ||
| 225 | -- Autocompletion | ||
| 226 | 'hrsh7th/nvim-cmp', | ||
| 227 | dependencies = { | ||
| 228 | -- Snippet Engine & its associated nvim-cmp source | ||
| 229 | 'L3MON4D3/LuaSnip', | ||
| 230 | 'saadparwaiz1/cmp_luasnip', | ||
| 231 | |||
| 232 | -- Adds LSP completion capabilities | ||
| 233 | 'hrsh7th/cmp-nvim-lsp', | ||
| 234 | |||
| 235 | -- Adds a number of user-friendly snippets | ||
| 236 | 'rafamadriz/friendly-snippets', | ||
| 237 | }, | ||
| 238 | }, | ||
| 239 | |||
| 240 | { | ||
| 241 | 'stevearc/aerial.nvim', | ||
| 242 | enable = false, | ||
| 243 | opts = {}, | ||
| 244 | -- Optional dependencies | ||
| 245 | dependencies = { | ||
| 246 | "nvim-treesitter/nvim-treesitter", | ||
| 247 | "nvim-tree/nvim-web-devicons" | ||
| 248 | }, | ||
| 249 | }, | ||
| 250 | |||
| 251 | |||
| 252 | --{ | ||
| 253 | -- -- Set lualine as statusline | ||
| 254 | -- 'nvim-lualine/lualine.nvim', | ||
| 255 | -- -- See `:help lualine.txt` | ||
| 256 | -- opts = { | ||
| 257 | -- options = { | ||
| 258 | -- icons_enabled = false, | ||
| 259 | -- theme = 'onedark', | ||
| 260 | -- component_separators = '|', | ||
| 261 | -- section_separators = { left = '', right = '' }, | ||
| 262 | -- }, | ||
| 263 | -- }, | ||
| 264 | --}, | ||
| 265 | |||
| 266 | { | ||
| 267 | -- Add indentation guides even on blank lines | ||
| 268 | 'lukas-reineke/indent-blankline.nvim', | ||
| 269 | -- Enable `lukas-reineke/indent-blankline.nvim` | ||
| 270 | -- See `:help ibl` | ||
| 271 | main = "ibl", | ||
| 272 | opts = { | ||
| 273 | indent = { char = "┊" }, | ||
| 274 | whitespace = { highlight = { "Whitespace", "NonText" } }, | ||
| 275 | }, | ||
| 276 | }, | ||
| 277 | |||
| 278 | -- "gc" to comment visual regions/lines | ||
| 279 | --{ 'numToStr/Comment.nvim', opts = {} }, | ||
| 280 | -- Another config | ||
| 281 | { | ||
| 282 | 'numToStr/Comment.nvim', | ||
| 283 | opts = { | ||
| 284 | opleader = { | ||
| 285 | ---Line-comment keymap | ||
| 286 | line = '<C-/>', | ||
| 287 | ---Block-comment keymap | ||
| 288 | block = 'gb', | ||
| 289 | }, | ||
| 290 | } | ||
| 291 | }, | ||
| 292 | |||
| 293 | |||
| 294 | -- Fuzzy Finder (files, lsp, etc) | ||
| 295 | { | ||
| 296 | 'nvim-telescope/telescope.nvim', | ||
| 297 | branch = '0.1.x', | ||
| 298 | dependencies = { | ||
| 299 | 'nvim-lua/plenary.nvim', | ||
| 300 | -- Fuzzy Finder Algorithm which requires local dependencies to be built. | ||
| 301 | -- Only load if `make` is available. Make sure you have the system | ||
| 302 | -- requirements installed. | ||
| 303 | { | ||
| 304 | 'nvim-telescope/telescope-fzf-native.nvim', | ||
| 305 | -- NOTE: If you are having trouble with this installation, | ||
| 306 | -- refer to the README for telescope-fzf-native for more instructions. | ||
| 307 | build = 'make', | ||
| 308 | cond = function() | ||
| 309 | return vim.fn.executable 'make' == 1 | ||
| 310 | end, | ||
| 311 | }, | ||
| 312 | 'cljoly/telescope-repo.nvim', | ||
| 313 | }, | ||
| 314 | }, | ||
| 315 | |||
| 316 | { | ||
| 317 | -- Highlight, edit, and navigate code | ||
| 318 | 'nvim-treesitter/nvim-treesitter', | ||
| 319 | dependencies = { | ||
| 320 | 'nvim-treesitter/nvim-treesitter-textobjects', | ||
| 321 | }, | ||
| 322 | build = ':TSUpdate', | ||
| 323 | }, | ||
| 324 | |||
| 325 | -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` | ||
| 326 | -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping | ||
| 327 | -- up-to-date with whatever is in the kickstart repo. | ||
| 328 | -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. | ||
| 329 | -- | ||
| 330 | -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins | ||
| 331 | -- { import = 'custom.plugins' }, | ||
| 332 | }, {}) | ||
| 333 | |||
| 334 | -- [[ Setting options ]] | ||
| 335 | -- See `:help vim.o` | ||
| 336 | |||
| 337 | -- Let cursor be line in insert mode | ||
| 338 | vim.opt.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" | ||
| 339 | |||
| 340 | -- Enable break indent | ||
| 341 | vim.o.breakindent = true | ||
| 342 | |||
| 343 | -- Set completeopt to have a better completion experience | ||
| 344 | vim.o.completeopt = 'menuone,noselect' | ||
| 345 | |||
| 346 | -- NOTE: You should make sure your terminal supports this | ||
| 347 | vim.o.termguicolors = true | ||
| 348 | |||
| 349 | -- [[ Basic Keymaps ]] | ||
| 350 | |||
| 351 | -- Keymaps for better default experience | ||
| 352 | -- See `:help vim.keymap.set()` | ||
| 353 | -- vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) | ||
| 354 | |||
| 355 | -- Use suda.vim to run sudo, or terminal prompt fails | ||
| 356 | -- See more details at https://github.com/neovim/neovim/issue | ||
| 357 | vim.cmd("command! W execute 'SudaWrite %'") | ||
| 358 | |||
| 359 | -- [[ Configure vim.surround ]] | ||
| 360 | vim.cmd('vmap s S') | ||
| 361 | |||
| 362 | -- [[ Configure lualine ]] | ||
| 363 | -- Change the background of lualine_b section for normal mode | ||
| 364 | -- local custom_wombat = require 'lualine.themes.wombat' | ||
| 365 | -- custom_wombat.normal.b.bg = '#a8a8a8' | ||
| 366 | -- custom_wombat.normal.b.fg = '#444444' | ||
| 367 | -- require('lualine').setup { | ||
| 368 | -- options = { theme = custom_wombat }, | ||
| 369 | -- } | ||
| 370 | |||
| 371 | -- [[ Configure lightline ]] | ||
| 372 | vim.cmd("let g:lightline = { 'colorscheme': 'wombat' }") | ||
| 373 | |||
| 374 | -- [[ Configure Goyo ]] | ||
| 375 | vim.cmd("nnoremap <silent> <leader>z :Goyo<CR>") | ||
| 376 | |||
| 377 | -- [[ Configure NERDTree ]] | ||
| 378 | vim.g.NERDTreeWinPos = 'left' | ||
| 379 | vim.g.NERDTreeShowHidden = 0 | ||
| 380 | vim.api.nvim_set_var('NERDTreeWinSize', 22) | ||
| 381 | vim.cmd("map <C-n> :NERDTreeToggle<cr>") | ||
| 382 | vim.cmd("map <leader>nb :NERDTreeFromBookmark<Space>") | ||
| 383 | vim.cmd("map <leader>nf :NERDTreeFind<cr>") | ||
| 384 | vim.o.autochdir = 0 | ||
| 385 | -- vim.cmd("autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif") | ||
| 386 | |||
| 387 | -- [ Configure Hop ] | ||
| 388 | vim.keymap.set('n', "<space>", ':HopWord<CR>') | ||
| 389 | vim.keymap.set('n', '<C-.>', ':HopChar1<CR>') | ||
| 390 | |||
| 391 | -- [[ Highlight on yank ]] | ||
| 392 | -- See `:help vim.highlight.on_yank()` | ||
| 393 | -- local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) | ||
| 394 | -- vim.api.nvim_create_autocmd('TextYankPost', { | ||
| 395 | -- callback = function() | ||
| 396 | -- vim.highlight.on_yank() | ||
| 397 | -- end, | ||
| 398 | -- group = highlight_group, | ||
| 399 | -- pattern = '*', | ||
| 400 | -- }) | ||
| 401 | |||
| 402 | -- [[ Configure Comment.nvim ]] | ||
| 403 | vim.cmd('nmap <C-/> V<C-/>') | ||
| 404 | |||
| 405 | -- [[ Configure Obsidian.nvim ]] | ||
| 406 | vim.keymap.set('n', "<leader>oo", ':Obsidian') | ||
| 407 | vim.keymap.set('n', "<leader>ot", ':ObsidianTags<CR>') | ||
| 408 | vim.keymap.set('n', "<leader>os", ':ObsidianSearch<CR>') | ||
| 409 | vim.keymap.set('n', "<leader>oq", ':ObsidianQuickSwitch<CR>') | ||
| 410 | vim.keymap.set('v', "<leader>on", ':ObsidianLinkNew<CR>') | ||
| 411 | |||
| 412 | -- vim.cmd("let g:mkdp_browser = 'surf'") | ||
| 413 | vim.cmd("let g:mkdp_browser = 'firefox'") | ||
| 414 | vim.g.mkdp_preview_options = { | ||
| 415 | mkit = { breaks = true }, | ||
| 416 | toc= { | ||
| 417 | containerClass = "toc", | ||
| 418 | format = 'function format(x, htmlencode) { return `<span>${htmlencode(x)}</span>`; }', | ||
| 419 | callback = "console.log('foo')", | ||
| 420 | } | ||
| 421 | } | ||
| 422 | |||
| 423 | -- The line beneath this is called `modeline`. See `:help modeline` | ||
| 424 | -- vim: ts=2 sts=2 sw=2 et | ||
diff --git a/vim/lazy/plugin/telescope.lua b/vim/lazy/plugin/telescope.lua deleted file mode 100644 index d6076b6..0000000 --- a/vim/lazy/plugin/telescope.lua +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | -- See `:help telescope` and `:help telescope.setup()` | ||
| 2 | |||
| 3 | require('telescope').setup { | ||
| 4 | defaults = { | ||
| 5 | mappings = { | ||
| 6 | i = { | ||
| 7 | -- ["<c-j>"] = "move_selection_next", | ||
| 8 | -- ["<c-k>"] = "move_selection_previous", | ||
| 9 | ["<C-w>"] = require("telescope.actions.layout").toggle_preview, | ||
| 10 | ["<C-u>"] = false, | ||
| 11 | }, | ||
| 12 | }, | ||
| 13 | layout_config = { | ||
| 14 | vertical = { height = 0.8 }, | ||
| 15 | -- other layout configuration here | ||
| 16 | preview_cutoff = 0, | ||
| 17 | }, | ||
| 18 | }, | ||
| 19 | pickers = { | ||
| 20 | buffers = { | ||
| 21 | show_all_buffers = true, | ||
| 22 | sort_lastused = true, | ||
| 23 | theme = "dropdown", | ||
| 24 | previewer = false, | ||
| 25 | mappings = { | ||
| 26 | i = { | ||
| 27 | ["<c-d>"] = "delete_buffer", | ||
| 28 | }, | ||
| 29 | n = { | ||
| 30 | ["<c-d>"] = "delete_buffer", | ||
| 31 | } | ||
| 32 | } | ||
| 33 | }, | ||
| 34 | |||
| 35 | }, | ||
| 36 | extensions = { | ||
| 37 | aerial = { | ||
| 38 | -- Display symbols as <root>.<parent>.<symbol> | ||
| 39 | show_nesting = { | ||
| 40 | ["_"] = false, -- This key will be the default | ||
| 41 | json = true, -- You can set the option for specific filetypes | ||
| 42 | yaml = true, | ||
| 43 | }, | ||
| 44 | }, | ||
| 45 | }, | ||
| 46 | } | ||
| 47 | |||
| 48 | -- Enable telescope fzf native, if installed | ||
| 49 | pcall(require('telescope').load_extension, 'fzf') | ||
| 50 | pcall(require('telescope').load_extension, 'repo') | ||
| 51 | |||
| 52 | -- See `:help telescope.builtin` | ||
| 53 | vim.keymap.set('n', '<leader>T', ':Telescope<CR>', { desc = '[T]elescope' }) | ||
| 54 | vim.keymap.set('n', '<leader>f', require('telescope.builtin').oldfiles, { desc = '[F] Find recently opened files' }) | ||
| 55 | vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = '[B] Find existing buffers' }) | ||
| 56 | vim.keymap.set('n', '<leader>st', require('telescope.builtin').builtin, { desc = '[S]earch [T]elescope for builtin' }) | ||
| 57 | vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) | ||
| 58 | vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) | ||
| 59 | vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) | ||
| 60 | vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) | ||
| 61 | vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) | ||
| 62 | vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) | ||
| 63 | vim.keymap.set('n', '<leader>sk', require('telescope.builtin').keymaps, { desc = '[S]earch [K]eymaps' }) | ||
| 64 | vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) | ||
| 65 | |||
| 66 | -- For grep in current buffer | ||
| 67 | vim.keymap.set('n', '<leader>/', function() | ||
| 68 | -- You can pass additional configuration to telescope to change theme, layout, etc. | ||
| 69 | require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { | ||
| 70 | --winblend = 10, | ||
| 71 | previewer = false, | ||
| 72 | }) | ||
| 73 | end, { desc = '[/] Fuzzily search in current buffer' }) | ||
| 74 | |||
| 75 | -- For neovim config files | ||
| 76 | vim.keymap.set('n', '<leader>sn', function() | ||
| 77 | require('telescope.builtin').find_files { | ||
| 78 | cwd = vim.fn.stdpath 'config', | ||
| 79 | follow = true | ||
| 80 | } | ||
| 81 | end, { desc = '[S]earch [N]eovim files' }) | ||
| 82 | |||
| 83 | -- Get snippets from ~/helper/snippets | ||
| 84 | vim.keymap.set('n', '<leader>ss', function() | ||
| 85 | local current_filetype = vim.bo.filetype | ||
| 86 | local cwd = '/home/pham/helper/snippets/' .. current_filetype | ||
| 87 | require('telescope.builtin').find_files { | ||
| 88 | prompt_title = 'Select a snippet for ' .. current_filetype, | ||
| 89 | cwd = cwd, | ||
| 90 | attach_mappings = function(prompt_bufnr, map) | ||
| 91 | local insert_selected_snippet = function() | ||
| 92 | local file = require('telescope.actions.state').get_selected_entry()[1] | ||
| 93 | local snippet_content = vim.fn.readfile(cwd .. "/" .. file) | ||
| 94 | require('telescope.actions').close(prompt_bufnr) | ||
| 95 | vim.api.nvim_command('normal! h') | ||
| 96 | vim.api.nvim_put(snippet_content, '', false, true) | ||
| 97 | end | ||
| 98 | |||
| 99 | map('i', '<CR>', insert_selected_snippet) | ||
| 100 | map('n', '<CR>', insert_selected_snippet) | ||
| 101 | |||
| 102 | return true | ||
| 103 | end, | ||
| 104 | } | ||
| 105 | end, { desc = '[S]earch [S]nippets' }) | ||
diff --git a/vim/lazy/plugin/treesitter.lua b/vim/lazy/plugin/treesitter.lua deleted file mode 100644 index 1ac6cd3..0000000 --- a/vim/lazy/plugin/treesitter.lua +++ /dev/null | |||
| @@ -1,231 +0,0 @@ | |||
| 1 | -- See `:help nvim-treesitter` | ||
| 2 | require('nvim-treesitter.configs').setup { | ||
| 3 | -- Add languages to be installed here that you want installed for treesitter | ||
| 4 | ensure_installed = { 'bash', 'c', 'html', 'css', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, | ||
| 5 | |||
| 6 | -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) | ||
| 7 | auto_install = false, | ||
| 8 | |||
| 9 | -- highlight = { enable = true }, | ||
| 10 | incremental_selection = { | ||
| 11 | enable = true, | ||
| 12 | keymaps = { | ||
| 13 | init_selection = '<c-space>', | ||
| 14 | node_incremental = '<c-space>', | ||
| 15 | scope_incremental = '<c-s>', | ||
| 16 | node_decremental = '<M-space>', | ||
| 17 | }, | ||
| 18 | }, | ||
| 19 | textobjects = { | ||
| 20 | select = { | ||
| 21 | enable = true, | ||
| 22 | lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim | ||
| 23 | keymaps = { | ||
| 24 | -- You can use the capture groups defined in textobjects.scm | ||
| 25 | ['aa'] = '@parameter.outer', | ||
| 26 | ['ia'] = '@parameter.inner', | ||
| 27 | ['if'] = '@function.inner', | ||
| 28 | ['af'] = '@function.outer', | ||
| 29 | ['ac'] = '@class.outer', | ||
| 30 | ['ic'] = '@class.inner', | ||
| 31 | }, | ||
| 32 | }, | ||
| 33 | move = { | ||
| 34 | enable = true, | ||
| 35 | set_jumps = true, -- whether to set jumps in the jumplist | ||
| 36 | goto_next_start = { | ||
| 37 | [']f'] = '@function.outer', | ||
| 38 | [']c'] = '@class.outer', | ||
| 39 | }, | ||
| 40 | goto_next_end = { | ||
| 41 | [']F'] = '@function.outer', | ||
| 42 | [']C'] = '@class.outer', | ||
| 43 | }, | ||
| 44 | goto_previous_start = { | ||
| 45 | ['[f'] = '@function.outer', | ||
| 46 | ['[c'] = '@class.outer', | ||
| 47 | }, | ||
| 48 | goto_previous_end = { | ||
| 49 | ['[F'] = '@function.outer', | ||
| 50 | ['[C'] = '@class.outer', | ||
| 51 | }, | ||
| 52 | }, | ||
| 53 | swap = { | ||
| 54 | enable = true, | ||
| 55 | swap_next = { | ||
| 56 | ['<leader>a'] = '@parameter.inner', | ||
| 57 | }, | ||
| 58 | swap_previous = { | ||
| 59 | ['<leader>A'] = '@parameter.inner', | ||
| 60 | }, | ||
| 61 | }, | ||
| 62 | }, | ||
| 63 | } | ||
| 64 | |||
| 65 | -- Diagnostic keymaps | ||
| 66 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) | ||
| 67 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) | ||
| 68 | vim.keymap.set('n', '<leader>E', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) | ||
| 69 | vim.keymap.set('n', '<leader>Q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) | ||
| 70 | |||
| 71 | |||
| 72 | -- [[ Configure Aerial ]] | ||
| 73 | require("aerial").setup({ | ||
| 74 | -- optionally use on_attach to set keymaps when aerial has attached to a buffer | ||
| 75 | on_attach = function(bufnr) | ||
| 76 | -- Jump forwards/backwards with '{' and '}' | ||
| 77 | vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr }) | ||
| 78 | vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr }) | ||
| 79 | end, | ||
| 80 | }) | ||
| 81 | vim.keymap.set("n", "<leader><leader>a", "<cmd>Telescope aerial<CR>") | ||
| 82 | vim.keymap.set("n", "<leader><leader>A", "<cmd>AerialToggle!left<CR>") | ||
| 83 | |||
| 84 | |||
| 85 | -- [[ Configure LSP ]] | ||
| 86 | -- This function gets run when an LSP connects to a particular buffer. | ||
| 87 | local on_attach = function(_, bufnr) | ||
| 88 | -- NOTE: Remember that lua is a real programming language, and as such it is possible | ||
| 89 | -- to define small helper and utility functions so you don't have to repeat yourself | ||
| 90 | -- many times. | ||
| 91 | -- | ||
| 92 | -- In this case, we create a function that lets us more easily define mappings specific | ||
| 93 | -- for LSP related items. It sets the mode, buffer and description for us each time. | ||
| 94 | local nmap = function(keys, func, desc) | ||
| 95 | if desc then | ||
| 96 | desc = 'LSP: ' .. desc | ||
| 97 | end | ||
| 98 | |||
| 99 | vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) | ||
| 100 | end | ||
| 101 | |||
| 102 | nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') | ||
| 103 | nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') | ||
| 104 | |||
| 105 | nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') | ||
| 106 | nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') | ||
| 107 | nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') | ||
| 108 | nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') | ||
| 109 | nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') | ||
| 110 | nmap('<leader><leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') | ||
| 111 | |||
| 112 | -- See `:help K` for why this keymap | ||
| 113 | nmap('K', vim.lsp.buf.hover, 'Hover Documentation') | ||
| 114 | -- nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') | ||
| 115 | |||
| 116 | -- Lesser used LSP functionality | ||
| 117 | nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') | ||
| 118 | nmap('<leader><leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') | ||
| 119 | nmap('<leader><leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') | ||
| 120 | nmap('<leader><leader>wl', function() | ||
| 121 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) | ||
| 122 | end, '[W]orkspace [L]ist Folders') | ||
| 123 | |||
| 124 | -- Create a command `:Format` local to the LSP buffer | ||
| 125 | vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) | ||
| 126 | vim.lsp.buf.format() | ||
| 127 | end, { desc = 'Format current buffer with LSP' }) | ||
| 128 | nmap('<leader>F', ':Format<CR>', 'Format code') | ||
| 129 | end | ||
| 130 | |||
| 131 | -- Enable the following language servers | ||
| 132 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. | ||
| 133 | -- | ||
| 134 | -- Add any additional override configuration in the following tables. They will be passed to | ||
| 135 | -- the `settings` field of the server config. You must look up that documentation yourself. | ||
| 136 | -- | ||
| 137 | -- If you want to override the default filetypes that your language server will attach to you can | ||
| 138 | -- define the property 'filetypes' to the map in question. | ||
| 139 | local servers = { | ||
| 140 | -- clangd = {}, | ||
| 141 | -- gopls = {}, | ||
| 142 | -- pyright = {}, | ||
| 143 | -- rust_analyzer = {}, | ||
| 144 | -- tsserver = {}, | ||
| 145 | -- html = { filetypes = { 'html', 'twig', 'hbs'} }, | ||
| 146 | tsserver = {}, | ||
| 147 | beancount = { | ||
| 148 | filetypes = { "beancount", "bean" }, | ||
| 149 | }, | ||
| 150 | |||
| 151 | lua_ls = { | ||
| 152 | Lua = { | ||
| 153 | workspace = { checkThirdParty = false }, | ||
| 154 | telemetry = { enable = false }, | ||
| 155 | diagnostics = { | ||
| 156 | -- Get the language server to recognize the `vim` global | ||
| 157 | globals = { 'vim' }, | ||
| 158 | }, | ||
| 159 | }, | ||
| 160 | }, | ||
| 161 | } | ||
| 162 | |||
| 163 | -- nvim-cmp supports additional completion capabilities, so broadcast that to servers | ||
| 164 | local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
| 165 | capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) | ||
| 166 | |||
| 167 | -- Ensure the servers above are installed | ||
| 168 | local mason_lspconfig = require 'mason-lspconfig' | ||
| 169 | |||
| 170 | mason_lspconfig.setup { | ||
| 171 | ensure_installed = vim.tbl_keys(servers), | ||
| 172 | } | ||
| 173 | |||
| 174 | mason_lspconfig.setup_handlers { | ||
| 175 | function(server_name) | ||
| 176 | require('lspconfig')[server_name].setup { | ||
| 177 | capabilities = capabilities, | ||
| 178 | on_attach = on_attach, | ||
| 179 | settings = servers[server_name], | ||
| 180 | filetypes = (servers[server_name] or {}).filetypes, | ||
| 181 | } | ||
| 182 | end | ||
| 183 | } | ||
| 184 | |||
| 185 | -- [[ Configure nvim-cmp ]] | ||
| 186 | -- See `:help cmp` | ||
| 187 | local cmp = require 'cmp' | ||
| 188 | local luasnip = require 'luasnip' | ||
| 189 | require('luasnip.loaders.from_vscode').lazy_load() | ||
| 190 | luasnip.config.setup {} | ||
| 191 | |||
| 192 | cmp.setup { | ||
| 193 | snippet = { | ||
| 194 | expand = function(args) | ||
| 195 | luasnip.lsp_expand(args.body) | ||
| 196 | end, | ||
| 197 | }, | ||
| 198 | mapping = cmp.mapping.preset.insert { | ||
| 199 | ['<C-n>'] = cmp.mapping.select_next_item(), | ||
| 200 | ['<C-p>'] = cmp.mapping.select_prev_item(), | ||
| 201 | ['<C-d>'] = cmp.mapping.scroll_docs(-4), | ||
| 202 | ['<C-u>'] = cmp.mapping.scroll_docs(4), | ||
| 203 | ['<C-Space>'] = cmp.mapping.complete {}, | ||
| 204 | ['<CR>'] = cmp.mapping.confirm { | ||
| 205 | behavior = cmp.ConfirmBehavior.Replace, | ||
| 206 | select = false, | ||
| 207 | }, | ||
| 208 | ['<Tab>'] = cmp.mapping(function(fallback) | ||
| 209 | if cmp.visible() then | ||
| 210 | cmp.select_next_item() | ||
| 211 | elseif luasnip.expand_or_locally_jumpable() then | ||
| 212 | luasnip.expand_or_jump() | ||
| 213 | else | ||
| 214 | fallback() | ||
| 215 | end | ||
| 216 | end, { 'i', 's' }), | ||
| 217 | ['<S-Tab>'] = cmp.mapping(function(fallback) | ||
| 218 | if cmp.visible() then | ||
| 219 | cmp.select_prev_item() | ||
| 220 | elseif luasnip.locally_jumpable(-1) then | ||
| 221 | luasnip.jump(-1) | ||
| 222 | else | ||
| 223 | fallback() | ||
| 224 | end | ||
| 225 | end, { 'i', 's' }), | ||
| 226 | }, | ||
| 227 | sources = { | ||
| 228 | { name = 'nvim_lsp' }, | ||
| 229 | { name = 'luasnip' }, | ||
| 230 | }, | ||
| 231 | } | ||
diff --git a/vim/nvim/init.vim b/vim/nvim/init.vim new file mode 100644 index 0000000..20a1c74 --- /dev/null +++ b/vim/nvim/init.vim | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | " Avoid load this script twice | ||
| 2 | if get(s:, 'loaded', 0) != 0 | ||
| 3 | finish | ||
| 4 | else | ||
| 5 | let s:loaded = 1 | ||
| 6 | endif | ||
| 7 | |||
| 8 | " Get current dir | ||
| 9 | " let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h') | ||
| 10 | let s:home = '~/helper/vim' | ||
| 11 | |||
| 12 | " Load script in current dir | ||
| 13 | " command! -nargs=1 LoadScript exec 'source '.s:home.'/'.'<args>' | ||
| 14 | |||
| 15 | " Add current dir into runtimepath | ||
| 16 | execute 'set runtimepath+='.s:home | ||
| 17 | |||
| 18 | |||
| 19 | "---------------------------------------------------------------------- | ||
| 20 | " Locad Modules | ||
| 21 | "---------------------------------------------------------------------- | ||
| 22 | |||
| 23 | " Basic configuration | ||
| 24 | source ~/helper/vim/init/basic.vim | ||
| 25 | |||
| 26 | " Key mappings | ||
| 27 | source ~/helper/vim/init/keymaps.vim | ||
| 28 | |||
| 29 | " Extra config for different contexts | ||
| 30 | source ~/helper/vim/init/config.vim | ||
| 31 | |||
| 32 | " Set tabsize | ||
| 33 | source ~/helper/vim/init/tabsize.vim | ||
| 34 | |||
| 35 | if has('nvim') | ||
| 36 | " For neovim | ||
| 37 | source ~/.config/nvim/lazy.lua | ||
| 38 | else | ||
| 39 | " For vim | ||
| 40 | source ~/helper/vim/init/plugins.vim | ||
| 41 | source ~/helper/vim/init/style.vim | ||
| 42 | endif | ||
| 43 | |||
| 44 | source ~/helper/vim/init/special_highlight.vim | ||
diff --git a/vim/nvim/lazy.lua b/vim/nvim/lazy.lua new file mode 100644 index 0000000..6cfadf0 --- /dev/null +++ b/vim/nvim/lazy.lua | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" | ||
| 2 | vim.g.mapleader = "," | ||
| 3 | |||
| 4 | -- bootstrap lazy and all plugins | ||
| 5 | local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" | ||
| 6 | |||
| 7 | if not vim.loop.fs_stat(lazypath) then | ||
| 8 | local repo = "https://github.com/folke/lazy.nvim.git" | ||
| 9 | vim.fn.system { "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath } | ||
| 10 | end | ||
| 11 | |||
| 12 | vim.opt.rtp:prepend(lazypath) | ||
| 13 | |||
| 14 | local lazy_config = require "configs.lazy" | ||
| 15 | |||
| 16 | -- load plugins | ||
| 17 | require("lazy").setup({ | ||
| 18 | { | ||
| 19 | "NvChad/NvChad", | ||
| 20 | lazy = false, | ||
| 21 | branch = "v2.5", | ||
| 22 | import = "nvchad.plugins", | ||
| 23 | config = function() | ||
| 24 | require "options" | ||
| 25 | end, | ||
| 26 | }, | ||
| 27 | |||
| 28 | { import = "plugins" }, | ||
| 29 | }, lazy_config) | ||
| 30 | |||
| 31 | -- load theme | ||
| 32 | dofile(vim.g.base46_cache .. "defaults") | ||
| 33 | dofile(vim.g.base46_cache .. "statusline") | ||
| 34 | |||
| 35 | require "nvchad.autocmds" | ||
| 36 | |||
| 37 | vim.schedule(function() | ||
| 38 | require "mappings" | ||
| 39 | end) | ||
diff --git a/vim/nvim/lua/chadrc.lua b/vim/nvim/lua/chadrc.lua new file mode 100644 index 0000000..aa0d78c --- /dev/null +++ b/vim/nvim/lua/chadrc.lua | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | -- This file needs to have same structure as nvconfig.lua | ||
| 2 | -- https://github.com/NvChad/NvChad/blob/v2.5/lua/nvconfig.lua | ||
| 3 | |||
| 4 | ---@type ChadrcConfig | ||
| 5 | local M = {} | ||
| 6 | |||
| 7 | M.ui = { | ||
| 8 | theme = "onedark", | ||
| 9 | |||
| 10 | -- hl_override = { | ||
| 11 | -- Comment = { italic = true }, | ||
| 12 | -- ["@comment"] = { italic = true }, | ||
| 13 | -- }, | ||
| 14 | tabufline = { | ||
| 15 | enabled = true, | ||
| 16 | }, | ||
| 17 | } | ||
| 18 | |||
| 19 | -- For tabufline | ||
| 20 | if M.ui.tabufline.enabled then | ||
| 21 | vim.keymap.set("n", "<C-c>", function() | ||
| 22 | local bufnrs = vim.tbl_filter(function(b) | ||
| 23 | if 1 ~= vim.fn.buflisted(b) then | ||
| 24 | return false | ||
| 25 | else | ||
| 26 | return true | ||
| 27 | end | ||
| 28 | end, vim.api.nvim_list_bufs()) | ||
| 29 | if #bufnrs == 1 then | ||
| 30 | vim.cmd("silent quit!") | ||
| 31 | else | ||
| 32 | require("nvchad.tabufline").close_buffer() | ||
| 33 | end | ||
| 34 | end, { desc = "buffer close" }) | ||
| 35 | for i = 1, 9, 1 do | ||
| 36 | vim.keymap.set("n", string.format("<A-%s>", i), function() | ||
| 37 | vim.api.nvim_set_current_buf(vim.t.bufs[i]) | ||
| 38 | end) | ||
| 39 | end | ||
| 40 | vim.keymap.set("n", "<A-h>", function() require("nvchad.tabufline").move_buf(-1) end) | ||
| 41 | vim.keymap.set("n", "<A-l>", function() require("nvchad.tabufline").move_buf(1) end) | ||
| 42 | vim.keymap.set("n", "<A-H>", function() vim.cmd("tabprevious") end) | ||
| 43 | vim.keymap.set("n", "<A-L>", function() vim.cmd("tabnext") end) | ||
| 44 | end | ||
| 45 | |||
| 46 | |||
| 47 | return M | ||
diff --git a/vim/nvim/lua/configs/conform.lua b/vim/nvim/lua/configs/conform.lua new file mode 100644 index 0000000..a000447 --- /dev/null +++ b/vim/nvim/lua/configs/conform.lua | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | local options = { | ||
| 2 | formatters_by_ft = { | ||
| 3 | lua = { "stylua" }, | ||
| 4 | -- css = { "prettier" }, | ||
| 5 | -- html = { "prettier" }, | ||
| 6 | }, | ||
| 7 | |||
| 8 | -- format_on_save = { | ||
| 9 | -- -- These options will be passed to conform.format() | ||
| 10 | -- timeout_ms = 500, | ||
| 11 | -- lsp_fallback = true, | ||
| 12 | -- }, | ||
| 13 | } | ||
| 14 | |||
| 15 | require("conform").setup(options) | ||
diff --git a/vim/nvim/lua/configs/lazy.lua b/vim/nvim/lua/configs/lazy.lua new file mode 100644 index 0000000..cd170bd --- /dev/null +++ b/vim/nvim/lua/configs/lazy.lua | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | return { | ||
| 2 | defaults = { lazy = true }, | ||
| 3 | install = { colorscheme = { "nvchad" } }, | ||
| 4 | |||
| 5 | ui = { | ||
| 6 | icons = { | ||
| 7 | ft = "", | ||
| 8 | lazy = " ", | ||
| 9 | loaded = "", | ||
| 10 | not_loaded = "", | ||
| 11 | }, | ||
| 12 | }, | ||
| 13 | |||
| 14 | performance = { | ||
| 15 | rtp = { | ||
| 16 | disabled_plugins = { | ||
| 17 | "2html_plugin", | ||
| 18 | "tohtml", | ||
| 19 | "getscript", | ||
| 20 | "getscriptPlugin", | ||
| 21 | "gzip", | ||
| 22 | "logipat", | ||
| 23 | "netrw", | ||
| 24 | "netrwPlugin", | ||
| 25 | "netrwSettings", | ||
| 26 | "netrwFileHandlers", | ||
| 27 | "matchit", | ||
| 28 | "tar", | ||
| 29 | "tarPlugin", | ||
| 30 | "rrhelper", | ||
| 31 | "spellfile_plugin", | ||
| 32 | "vimball", | ||
| 33 | "vimballPlugin", | ||
| 34 | "zip", | ||
| 35 | "zipPlugin", | ||
| 36 | "tutor", | ||
| 37 | "rplugin", | ||
| 38 | "syntax", | ||
| 39 | "synmenu", | ||
| 40 | "optwin", | ||
| 41 | "compiler", | ||
| 42 | "bugreport", | ||
| 43 | "ftplugin", | ||
| 44 | }, | ||
| 45 | }, | ||
| 46 | }, | ||
| 47 | } | ||
diff --git a/vim/nvim/lua/configs/lspconfig.lua b/vim/nvim/lua/configs/lspconfig.lua new file mode 100644 index 0000000..a73657a --- /dev/null +++ b/vim/nvim/lua/configs/lspconfig.lua | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | -- EXAMPLE | ||
| 2 | local on_attach = require("nvchad.configs.lspconfig").on_attach | ||
| 3 | local on_init = require("nvchad.configs.lspconfig").on_init | ||
| 4 | local capabilities = require("nvchad.configs.lspconfig").capabilities | ||
| 5 | |||
| 6 | local lspconfig = require "lspconfig" | ||
| 7 | local servers = { "html", "cssls" } | ||
| 8 | |||
| 9 | -- lsps with default config | ||
| 10 | for _, lsp in ipairs(servers) do | ||
| 11 | lspconfig[lsp].setup { | ||
| 12 | on_attach = on_attach, | ||
| 13 | on_init = on_init, | ||
| 14 | capabilities = capabilities, | ||
| 15 | } | ||
| 16 | end | ||
| 17 | |||
| 18 | -- typescript | ||
| 19 | lspconfig.tsserver.setup { | ||
| 20 | on_attach = on_attach, | ||
| 21 | on_init = on_init, | ||
| 22 | capabilities = capabilities, | ||
| 23 | } | ||
diff --git a/vim/nvim/lua/configs/telescope.lua b/vim/nvim/lua/configs/telescope.lua new file mode 100644 index 0000000..73c64e5 --- /dev/null +++ b/vim/nvim/lua/configs/telescope.lua | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | return { | ||
| 2 | defaults = { | ||
| 3 | mappings = { | ||
| 4 | i = { | ||
| 5 | -- ["<c-j>"] = "move_selection_next", | ||
| 6 | -- ["<c-k>"] = "move_selection_previous", | ||
| 7 | ["<C-w>"] = require("telescope.actions.layout").toggle_preview, | ||
| 8 | ["<C-u>"] = false, | ||
| 9 | }, | ||
| 10 | }, | ||
| 11 | layout_config = { | ||
| 12 | horizontal = { | ||
| 13 | prompt_position = "bottom", | ||
| 14 | }, | ||
| 15 | vertical = { height = 0.8 }, | ||
| 16 | -- other layout configuration here | ||
| 17 | preview_cutoff = 0, | ||
| 18 | }, | ||
| 19 | }, | ||
| 20 | pickers = { | ||
| 21 | buffers = { | ||
| 22 | show_all_buffers = true, | ||
| 23 | sort_lastused = true, | ||
| 24 | theme = "dropdown", | ||
| 25 | previewer = false, | ||
| 26 | mappings = { | ||
| 27 | i = { | ||
| 28 | ["<c-d>"] = "delete_buffer", | ||
| 29 | }, | ||
| 30 | n = { | ||
| 31 | ["<c-d>"] = "delete_buffer", | ||
| 32 | } | ||
| 33 | } | ||
| 34 | }, | ||
| 35 | |||
| 36 | }, | ||
| 37 | extensions_list = {}, | ||
| 38 | extensions = { | ||
| 39 | aerial = { | ||
| 40 | -- Display symbols as <root>.<parent>.<symbol> | ||
| 41 | show_nesting = { | ||
| 42 | ["_"] = false, -- This key will be the default | ||
| 43 | json = true, -- You can set the option for specific filetypes | ||
| 44 | yaml = true, | ||
| 45 | }, | ||
| 46 | }, | ||
| 47 | }, | ||
| 48 | } | ||
diff --git a/vim/nvim/lua/configs/treesitter.lua b/vim/nvim/lua/configs/treesitter.lua new file mode 100644 index 0000000..8375d5b --- /dev/null +++ b/vim/nvim/lua/configs/treesitter.lua | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | return { | ||
| 2 | -- Add languages to be installed here that you want installed for treesitter | ||
| 3 | ensure_installed = { 'bash', 'c', 'html', 'css', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, | ||
| 4 | |||
| 5 | -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) | ||
| 6 | auto_install = true, | ||
| 7 | |||
| 8 | -- highlight = { enable = true }, | ||
| 9 | incremental_selection = { | ||
| 10 | enable = true, | ||
| 11 | keymaps = { | ||
| 12 | init_selection = '<c-space>', | ||
| 13 | node_incremental = '<c-space>', | ||
| 14 | scope_incremental = '<c-s>', | ||
| 15 | node_decremental = '<M-space>', | ||
| 16 | }, | ||
| 17 | }, | ||
| 18 | textobjects = { | ||
| 19 | select = { | ||
| 20 | enable = true, | ||
| 21 | lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim | ||
| 22 | keymaps = { | ||
| 23 | -- You can use the capture groups defined in textobjects.scm | ||
| 24 | ['aa'] = '@parameter.outer', | ||
| 25 | ['ia'] = '@parameter.inner', | ||
| 26 | ['af'] = '@function.outer', | ||
| 27 | ['if'] = '@function.inner', | ||
| 28 | ['ac'] = '@class.outer', | ||
| 29 | ['ic'] = '@class.inner', | ||
| 30 | }, | ||
| 31 | }, | ||
| 32 | move = { | ||
| 33 | enable = true, | ||
| 34 | set_jumps = true, -- whether to set jumps in the jumplist | ||
| 35 | goto_next_start = { | ||
| 36 | [']f'] = '@function.outer', | ||
| 37 | [']c'] = '@class.outer', | ||
| 38 | }, | ||
| 39 | goto_next_end = { | ||
| 40 | [']F'] = '@function.outer', | ||
| 41 | [']C'] = '@class.outer', | ||
| 42 | }, | ||
| 43 | goto_previous_start = { | ||
| 44 | ['[f'] = '@function.outer', | ||
| 45 | ['[c'] = '@class.outer', | ||
| 46 | }, | ||
| 47 | goto_previous_end = { | ||
| 48 | ['[F'] = '@function.outer', | ||
| 49 | ['[C'] = '@class.outer', | ||
| 50 | }, | ||
| 51 | }, | ||
| 52 | swap = { | ||
| 53 | enable = true, | ||
| 54 | swap_next = { | ||
| 55 | ['<leader>a'] = '@parameter.inner', | ||
| 56 | }, | ||
| 57 | swap_previous = { | ||
| 58 | ['<leader>A'] = '@parameter.inner', | ||
| 59 | }, | ||
| 60 | }, | ||
| 61 | }, | ||
| 62 | } | ||
diff --git a/vim/nvim/lua/mappings.lua b/vim/nvim/lua/mappings.lua new file mode 100644 index 0000000..f6ef8c4 --- /dev/null +++ b/vim/nvim/lua/mappings.lua | |||
| @@ -0,0 +1,170 @@ | |||
| 1 | -- require "nvchad.mappings" | ||
| 2 | |||
| 3 | -- add yours here | ||
| 4 | |||
| 5 | local map = vim.keymap.set | ||
| 6 | |||
| 7 | map("i", "jk", "<ESC>") | ||
| 8 | vim.cmd("command! W execute 'SudaWrite %'") | ||
| 9 | |||
| 10 | -- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>") | ||
| 11 | |||
| 12 | map("n", "<Esc>", "<cmd>noh<CR>", { desc = "general clear highlights" }) | ||
| 13 | |||
| 14 | -- map("n", "<C-c>", "<cmd>%y+<CR>", { desc = "file copy whole" }) | ||
| 15 | |||
| 16 | -- map("n", "<leader>n", "<cmd>set nu!<CR>", { desc = "toggle line number" }) | ||
| 17 | -- map("n", "<leader>rn", "<cmd>set rnu!<CR>", { desc = "toggle relative number" }) | ||
| 18 | map("n", "<leader>ch", "<cmd>NvCheatsheet<CR>", { desc = "toggle nvcheatsheet" }) | ||
| 19 | |||
| 20 | map("n", "<leader>F", function() | ||
| 21 | require("conform").format { lsp_fallback = true } | ||
| 22 | end, { desc = "format files" }) | ||
| 23 | |||
| 24 | -- global lsp mappings | ||
| 25 | map("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) | ||
| 26 | |||
| 27 | -- tabufline | ||
| 28 | map("n", "<tab>", function() | ||
| 29 | require("nvchad.tabufline").next() | ||
| 30 | end, { desc = "buffer goto next" }) | ||
| 31 | |||
| 32 | map("n", "<S-tab>", function() | ||
| 33 | require("nvchad.tabufline").prev() | ||
| 34 | end, { desc = "buffer goto prev" }) | ||
| 35 | |||
| 36 | map("n", "<leader>x", function() | ||
| 37 | require("nvchad.tabufline").close_buffer() | ||
| 38 | end, { desc = "buffer close" }) | ||
| 39 | |||
| 40 | -- Comment | ||
| 41 | map("n", "<leader>/", "gcc", { desc = "comment toggle", remap = true }) | ||
| 42 | map("v", "<leader>/", "gc", { desc = "comment toggle", remap = true }) | ||
| 43 | |||
| 44 | -- nvimtree | ||
| 45 | map("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "nvimtree toggle window" }) | ||
| 46 | map("n", "<leader>nf", "<cmd>NvimTreeFocus<CR>", { desc = "nvimtree focus window" }) | ||
| 47 | |||
| 48 | -- telescope | ||
| 49 | map("n", "<leader>f", "<cmd>Telescope oldfiles<CR>", { desc = "telescope find oldfiles" }) | ||
| 50 | map("n", "<leader>b", "<cmd>Telescope buffers<CR>", { desc = "telescope find buffers" }) | ||
| 51 | map("n", "<leader>/", "<cmd>Telescope current_buffer_fuzzy_find<CR>", { desc = "telescope find in current buffer" }) | ||
| 52 | map("n", "<leader>sf", "<cmd>Telescope find_files<cr>", { desc = "telescope find files" }) | ||
| 53 | map("n", "<leader>sF", "<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>", | ||
| 54 | { desc = "telescope find all files" }) | ||
| 55 | map("n", "<leader>sg", "<cmd>Telescope live_grep<CR>", { desc = "telescope live grep" }) | ||
| 56 | |||
| 57 | map("n", "<leader>gf", "<cmd>Telescope git_files<CR>", { desc = "telescope git files" }) | ||
| 58 | map("n", "<leader>sH", "<cmd>Telescope help_tags<CR>", { desc = "telescope help page" }) | ||
| 59 | map("n", "<leader>tt", ":Telescope ", { desc = "telescope help page" }) | ||
| 60 | map('n', '<leader>sk', "<cmd>Telescope keymaps<CR>", { desc = 'telescope keymaps' }) | ||
| 61 | map("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "telescope pick hidden term" }) | ||
| 62 | |||
| 63 | vim.keymap.set('n', '<leader>ss', function() | ||
| 64 | local current_filetype = vim.bo.filetype | ||
| 65 | local cwd = os.getenv("HOME") .. '/snippets/' .. current_filetype | ||
| 66 | require('telescope.builtin').find_files { | ||
| 67 | prompt_title = 'Select a snippet for ' .. current_filetype, | ||
| 68 | cwd = cwd, | ||
| 69 | attach_mappings = function(prompt_bufnr, map) | ||
| 70 | local insert_selected_snippet = function() | ||
| 71 | local file = require('telescope.actions.state').get_selected_entry()[1] | ||
| 72 | local snippet_content = vim.fn.readfile(cwd .. "/" .. file) | ||
| 73 | require('telescope.actions').close(prompt_bufnr) | ||
| 74 | vim.api.nvim_put(snippet_content, '', false, true) | ||
| 75 | end | ||
| 76 | |||
| 77 | map('i', '<CR>', insert_selected_snippet) | ||
| 78 | map('n', '<CR>', insert_selected_snippet) | ||
| 79 | |||
| 80 | return true | ||
| 81 | end, | ||
| 82 | } | ||
| 83 | end, { desc = '[S]earch [S]nippets' }) | ||
| 84 | |||
| 85 | vim.keymap.set('n', '<leader>sn', function() | ||
| 86 | vim.ui.input({ prompt = 'Snippet Name: ' }, function(snippet_path) | ||
| 87 | local current_filetype | ||
| 88 | local snippet | ||
| 89 | if string.find(snippet_path, "/") then | ||
| 90 | current_filetype = string.match(snippet_path, "^(.-)/") | ||
| 91 | snippet = string.match(snippet_path, "/(.-)$") | ||
| 92 | else | ||
| 93 | current_filetype = vim.bo.filetype | ||
| 94 | snippet = snippet_path | ||
| 95 | end | ||
| 96 | local dir = os.getenv("HOME") .. '/snippets/' .. current_filetype | ||
| 97 | local path = dir .. '/' .. snippet | ||
| 98 | vim.cmd("!mkdir -p" .. dir) | ||
| 99 | vim.cmd("e " .. path) | ||
| 100 | vim.cmd("set filetype=" .. current_filetype) | ||
| 101 | vim.cmd("set filetype?") | ||
| 102 | end) | ||
| 103 | end, { desc = "Create a new snippet" }) | ||
| 104 | |||
| 105 | |||
| 106 | -- map("n", "<leader>ma", "<cmd>Telescope marks<CR>", { desc = "telescope find marks" }) | ||
| 107 | -- map("n", "<leader>cm", "<cmd>Telescope git_commits<CR>", { desc = "telescope git commits" }) | ||
| 108 | -- map("n", "<leader>gt", "<cmd>Telescope git_status<CR>", { desc = "telescope git status" }) | ||
| 109 | -- map("n", "<leader>th", "<cmd>Telescope themes<CR>", { desc = "telescope nvchad themes" }) | ||
| 110 | |||
| 111 | -- terminal | ||
| 112 | -- map("t", "<C-x>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" }) | ||
| 113 | |||
| 114 | -- new terminals | ||
| 115 | map("n", "<leader><leader>h", function() require("nvchad.term").new { pos = "sp" } end, | ||
| 116 | { desc = "terminal new horizontal term" }) | ||
| 117 | map("n", "<leader>v", function() require("nvchad.term").new { pos = "vsp" } end, | ||
| 118 | { desc = "terminal new vertical window" }) | ||
| 119 | -- toggleable | ||
| 120 | map({ "n", "t" }, "<A-v>", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } end, | ||
| 121 | { desc = "terminal toggleable vertical term" }) | ||
| 122 | map({ "n", "t" }, "<A-t>", function() require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } end, | ||
| 123 | { desc = "terminal new horizontal term" }) | ||
| 124 | map({ "n", "t" }, "<A-i>", function() require("nvchad.term").toggle { pos = "float", id = "floatTerm" } end, | ||
| 125 | { desc = "terminal toggle floating term" }) | ||
| 126 | |||
| 127 | -- whichkey | ||
| 128 | map("n", "<leader>wK", "<cmd>WhichKey <CR>", { desc = "whichkey all keymaps" }) | ||
| 129 | |||
| 130 | map("n", "<leader>wk", function() | ||
| 131 | vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") | ||
| 132 | end, { desc = "whichkey query lookup" }) | ||
| 133 | |||
| 134 | -- blankline | ||
| 135 | map("n", "<leader>cc", function() | ||
| 136 | local config = { scope = {} } | ||
| 137 | config.scope.exclude = { language = {}, node_type = {} } | ||
| 138 | config.scope.include = { node_type = {} } | ||
| 139 | local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) | ||
| 140 | |||
| 141 | if node then | ||
| 142 | local start_row, _, end_row, _ = node:range() | ||
| 143 | if start_row ~= end_row then | ||
| 144 | vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) | ||
| 145 | vim.api.nvim_feedkeys("_", "n", true) | ||
| 146 | end | ||
| 147 | end | ||
| 148 | end, { desc = "blankline jump to current context" }) | ||
| 149 | |||
| 150 | -- [[ Configure Obsidian.nvim ]] | ||
| 151 | map('n', "<leader>oo", ':Obsidian') | ||
| 152 | map('n', "<leader>ot", ':ObsidianTags<CR>') | ||
| 153 | map('n', "<leader>os", ':ObsidianSearch<CR>') | ||
| 154 | map('n', "<leader>oq", ':ObsidianQuickSwitch<CR>') | ||
| 155 | map('v', "<leader>on", ':ObsidianLinkNew<CR>') | ||
| 156 | |||
| 157 | -- vim.cmd("let g:mkdp_browser = 'surf'") | ||
| 158 | vim.cmd("let g:mkdp_browser = 'firefox'") | ||
| 159 | vim.g.mkdp_preview_options = { | ||
| 160 | mkit = { breaks = true }, | ||
| 161 | toc = { | ||
| 162 | containerClass = "toc", | ||
| 163 | format = 'function format(x, htmlencode) { return `<span>${htmlencode(x)}</span>`; }', | ||
| 164 | callback = "console.log('foo')", | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | -- [ Configure Hop ] | ||
| 169 | vim.keymap.set('n', "<space>", ':HopWord<CR>') | ||
| 170 | vim.keymap.set('n', '<C-.>', ':HopChar1<CR>') | ||
diff --git a/vim/nvim/lua/options.lua b/vim/nvim/lua/options.lua new file mode 100644 index 0000000..f9e6e7e --- /dev/null +++ b/vim/nvim/lua/options.lua | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | require "nvchad.options" | ||
| 2 | |||
| 3 | -- add yours here! | ||
| 4 | |||
| 5 | local o = vim.o | ||
| 6 | |||
| 7 | -- To enable cursorline! | ||
| 8 | o.cursorlineopt ='both' | ||
| 9 | |||
| 10 | -- Let cursor be line in insert mode | ||
| 11 | o.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" | ||
| 12 | |||
| 13 | -- Enable break indent | ||
| 14 | o.breakindent = true | ||
| 15 | |||
| 16 | -- To have a better completion experience | ||
| 17 | o.completeopt = 'menuone,noselect' | ||
| 18 | |||
| 19 | -- NOTE: You should make sure your terminal supports this | ||
| 20 | o.termguicolors = true | ||
diff --git a/vim/nvim/lua/plugins/init.lua b/vim/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..132f1a2 --- /dev/null +++ b/vim/nvim/lua/plugins/init.lua | |||
| @@ -0,0 +1,218 @@ | |||
| 1 | return { | ||
| 2 | |||
| 3 | -- Detect tabstop and shiftwidth automatically | ||
| 4 | 'tpope/vim-sleuth', | ||
| 5 | |||
| 6 | -- Use sudo in command mode | ||
| 7 | { | ||
| 8 | 'lambdalisue/suda.vim', | ||
| 9 | cmd = { "SudaWrite" }, | ||
| 10 | }, | ||
| 11 | |||
| 12 | -- For focus mode | ||
| 13 | { | ||
| 14 | "Pocco81/true-zen.nvim", | ||
| 15 | cmd = { "TZAtaraxis", "TZMinimalist" }, | ||
| 16 | }, | ||
| 17 | |||
| 18 | -- hop.nvim: For quick jump | ||
| 19 | { | ||
| 20 | 'smoka7/hop.nvim', | ||
| 21 | lazy = false, | ||
| 22 | version = "*", | ||
| 23 | opts = { | ||
| 24 | keys = 'etovxqpdygfblzhckisuran' | ||
| 25 | }, | ||
| 26 | config = function() | ||
| 27 | require("hop").setup() | ||
| 28 | end | ||
| 29 | }, | ||
| 30 | |||
| 31 | { | ||
| 32 | "stevearc/conform.nvim", | ||
| 33 | -- event = 'BufWritePre', -- uncomment for format on save | ||
| 34 | config = function() | ||
| 35 | require "configs.conform" | ||
| 36 | end, | ||
| 37 | }, | ||
| 38 | |||
| 39 | { | ||
| 40 | -- Add indentation guides even on blank lines | ||
| 41 | 'lukas-reineke/indent-blankline.nvim', | ||
| 42 | -- See `:help ibl` | ||
| 43 | enabled = false, | ||
| 44 | main = "ibl", | ||
| 45 | opts = { | ||
| 46 | indent = { char = "┊" }, | ||
| 47 | whitespace = { highlight = { "Whitespace", "NonText" } }, | ||
| 48 | }, | ||
| 49 | }, | ||
| 50 | |||
| 51 | { | ||
| 52 | 'lewis6991/gitsigns.nvim', | ||
| 53 | opts = { | ||
| 54 | -- See `:help gitsigns.txt` | ||
| 55 | signs = { | ||
| 56 | add = { text = '+' }, | ||
| 57 | change = { text = '~' }, | ||
| 58 | delete = { text = '_' }, | ||
| 59 | topdelete = { text = '‾' }, | ||
| 60 | changedelete = { text = '~' }, | ||
| 61 | }, | ||
| 62 | on_attach = function(bufnr) | ||
| 63 | vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, | ||
| 64 | { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) | ||
| 65 | vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) | ||
| 66 | vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) | ||
| 67 | vim.keymap.set('n', '<leader>hd', require('gitsigns').diffthis, { buffer = bufnr, desc = '[h]unk [d]iff' }) | ||
| 68 | vim.keymap.set('n', '<leader>hD', function() require('gitsigns').diffthis('~') end, | ||
| 69 | { buffer = bufnr, desc = '[h]unk [d]iff for ~' }) | ||
| 70 | vim.keymap.set('v', 'hr', ":Gitsigns reset_hunk<CR>", { buffer = bufnr, desc = '[h]unk [r]eset' }) | ||
| 71 | end, | ||
| 72 | }, | ||
| 73 | }, | ||
| 74 | |||
| 75 | { | ||
| 76 | "epwalsh/obsidian.nvim", | ||
| 77 | version = "*", -- recommended, use latest release instead of latest commit | ||
| 78 | lazy = true, | ||
| 79 | ft = "markdown", | ||
| 80 | -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: | ||
| 81 | -- event = { | ||
| 82 | -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. | ||
| 83 | -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" | ||
| 84 | -- "BufReadPre path/to/my-vault/**.md", | ||
| 85 | -- "BufNewFile path/to/my-vault/**.md", | ||
| 86 | -- }, | ||
| 87 | dependencies = { | ||
| 88 | -- Required. | ||
| 89 | "nvim-lua/plenary.nvim", | ||
| 90 | }, | ||
| 91 | opts = { | ||
| 92 | workspaces = { | ||
| 93 | { | ||
| 94 | name = "log", | ||
| 95 | path = "~/log", | ||
| 96 | }, | ||
| 97 | }, | ||
| 98 | completion = { | ||
| 99 | -- Set to false to disable completion. | ||
| 100 | nvim_cmp = true, | ||
| 101 | -- Trigger completion at 2 chars. | ||
| 102 | min_chars = 2, | ||
| 103 | }, | ||
| 104 | mapping = { | ||
| 105 | -- Toggle check-boxes. | ||
| 106 | ["<leader>oc"] = { | ||
| 107 | action = function() | ||
| 108 | return require("obsidian").util.toggle_checkbox() | ||
| 109 | end, | ||
| 110 | opts = { buffer = true }, | ||
| 111 | }, | ||
| 112 | -- Smart action depending on context, either follow link or toggle checkbox. | ||
| 113 | ["<cr>"] = { | ||
| 114 | action = function() | ||
| 115 | return require("obsidian").util.smart_action() | ||
| 116 | end, | ||
| 117 | opts = { buffer = true, expr = true }, | ||
| 118 | } | ||
| 119 | }, | ||
| 120 | -- see below for full list of options 👇 | ||
| 121 | note_id_func = function(title) | ||
| 122 | return title | ||
| 123 | -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. | ||
| 124 | -- In this case a note with the title 'My new note' will be given an ID that looks | ||
| 125 | -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' | ||
| 126 | -- local suffix = "" | ||
| 127 | -- title = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() | ||
| 128 | -- if title ~= nil and title ~= "" then | ||
| 129 | -- -- If title is given, transform it into valid file name. | ||
| 130 | -- suffix = "-" .. title | ||
| 131 | -- else | ||
| 132 | -- -- If title is nil, just add 4 random uppercase letters to the suffix. | ||
| 133 | -- for _ = 1, 4 do | ||
| 134 | -- suffix = suffix .. string.char(math.random(65, 90)) | ||
| 135 | -- end | ||
| 136 | -- suffix = "-" .. title | ||
| 137 | -- end | ||
| 138 | -- return tostring(os.time()) .. suffix | ||
| 139 | end, | ||
| 140 | }, | ||
| 141 | }, | ||
| 142 | |||
| 143 | { | ||
| 144 | "iamcco/markdown-preview.nvim", | ||
| 145 | cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, | ||
| 146 | ft = { "markdown" }, | ||
| 147 | build = function() vim.fn["mkdp#util#install"]() end, | ||
| 148 | }, | ||
| 149 | |||
| 150 | { | ||
| 151 | "nvim-telescope/telescope.nvim", | ||
| 152 | opts = function() | ||
| 153 | return require "configs.telescope" | ||
| 154 | end, | ||
| 155 | }, | ||
| 156 | |||
| 157 | { | ||
| 158 | "nvim-treesitter/nvim-treesitter", | ||
| 159 | dependencies = { | ||
| 160 | 'nvim-treesitter/nvim-treesitter-textobjects', | ||
| 161 | }, | ||
| 162 | opts = function() | ||
| 163 | return require "configs.treesitter" | ||
| 164 | end, | ||
| 165 | }, | ||
| 166 | |||
| 167 | { | ||
| 168 | 'stevearc/aerial.nvim', | ||
| 169 | lazy = false, | ||
| 170 | event = { "BufReadPost", "BufWritePost", "BufNewFile" }, | ||
| 171 | opts = { | ||
| 172 | on_attach = function(bufnr) | ||
| 173 | -- Jump forwards/backwards with '{' and '}' | ||
| 174 | vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr }) | ||
| 175 | vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr }) | ||
| 176 | vim.keymap.set("n", "<leader><leader>a", "<cmd>Telescope aerial<CR>") | ||
| 177 | vim.keymap.set("n", "<leader><leader>A", "<cmd>AerialToggle!left<CR>") | ||
| 178 | end, | ||
| 179 | }, | ||
| 180 | -- Optional dependencies | ||
| 181 | dependencies = { | ||
| 182 | "nvim-treesitter/nvim-treesitter", | ||
| 183 | "nvim-tree/nvim-web-devicons" | ||
| 184 | }, | ||
| 185 | }, | ||
| 186 | |||
| 187 | -- { | ||
| 188 | -- 'numToStr/Comment.nvim', | ||
| 189 | -- lazy = true, | ||
| 190 | -- opts = { | ||
| 191 | -- opleader = { | ||
| 192 | -- ---Line-comment keymap | ||
| 193 | -- line = '<C-/>', | ||
| 194 | -- ---Block-comment keymap | ||
| 195 | -- block = 'gb', | ||
| 196 | -- }, | ||
| 197 | -- } | ||
| 198 | -- }, | ||
| 199 | |||
| 200 | -- These are some examples, uncomment them if you want to see them work! | ||
| 201 | -- { | ||
| 202 | -- "neovim/nvim-lspconfig", | ||
| 203 | -- config = function() | ||
| 204 | -- require("nvchad.configs.lspconfig").defaults() | ||
| 205 | -- require "configs.lspconfig" | ||
| 206 | -- end, | ||
| 207 | -- }, | ||
| 208 | -- | ||
| 209 | -- { | ||
| 210 | -- "williamboman/mason.nvim", | ||
| 211 | -- opts = { | ||
| 212 | -- ensure_installed = { | ||
| 213 | -- "lua-language-server", "stylua", | ||
| 214 | -- "html-lsp", "css-lsp" , "prettier" | ||
| 215 | -- }, | ||
| 216 | -- }, | ||
| 217 | -- }, | ||
| 218 | } | ||