diff options
Diffstat (limited to 'vim/lazy')
| -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 |
3 files changed, 0 insertions, 760 deletions
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 | } | ||