diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2023-07-11 09:05:17 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2023-07-11 09:05:17 +0800 |
| commit | bc2f281be3a825862c667fd5762c764798b0b959 (patch) | |
| tree | d106f6b397ae7452a7d9055b999fcf8206986b1c | |
| parent | de0b1f3031429a828d80dde2b240eb266c9bee53 (diff) | |
Update
| -rw-r--r-- | init.lua | 66 |
1 files changed, 40 insertions, 26 deletions
| @@ -35,7 +35,6 @@ I hope you enjoy your Neovim journey, | |||
| 35 | 35 | ||
| 36 | P.S. You can delete this when you're done too. It's your config now :) | 36 | P.S. You can delete this when you're done too. It's your config now :) |
| 37 | --]] | 37 | --]] |
| 38 | |||
| 39 | -- [[ General Config ]] | 38 | -- [[ General Config ]] |
| 40 | vim.cmd('source ' .. '~/.vim/vim-init/init/init-basic.vim') | 39 | vim.cmd('source ' .. '~/.vim/vim-init/init/init-basic.vim') |
| 41 | vim.cmd('source ' .. '~/.vim/vim-init/init/init-keymaps.vim') | 40 | vim.cmd('source ' .. '~/.vim/vim-init/init/init-keymaps.vim') |
| @@ -44,7 +43,7 @@ vim.cmd('source ' .. '~/.vim/vim-init/init/init-keymaps.vim') | |||
| 44 | -- Install package manager | 43 | -- Install package manager |
| 45 | -- https://github.com/folke/lazy.nvim | 44 | -- https://github.com/folke/lazy.nvim |
| 46 | -- `:help lazy.nvim.txt` for more info | 45 | -- `:help lazy.nvim.txt` for more info |
| 47 | local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' | 46 | local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' |
| 48 | if not vim.loop.fs_stat(lazypath) then | 47 | if not vim.loop.fs_stat(lazypath) then |
| 49 | vim.fn.system { | 48 | vim.fn.system { |
| 50 | 'git', | 49 | 'git', |
| @@ -55,7 +54,7 @@ if not vim.loop.fs_stat(lazypath) then | |||
| 55 | lazypath, | 54 | lazypath, |
| 56 | } | 55 | } |
| 57 | end | 56 | end |
| 58 | vim.opt.rtp:prepend(lazypath) | 57 | vim.opt.runtimepath:prepend(lazypath) |
| 59 | 58 | ||
| 60 | -- NOTE: Here is where you install your plugins. | 59 | -- NOTE: Here is where you install your plugins. |
| 61 | -- You can configure plugins using the `config` key. | 60 | -- You can configure plugins using the `config` key. |
| @@ -76,7 +75,8 @@ require('lazy').setup({ | |||
| 76 | 75 | ||
| 77 | -- NOTE: This is where your plugins related to LSP can be installed. | 76 | -- NOTE: This is where your plugins related to LSP can be installed. |
| 78 | -- The configuration is done below. Search for lspconfig to find it below. | 77 | -- The configuration is done below. Search for lspconfig to find it below. |
| 79 | { -- LSP Configuration & Plugins | 78 | { |
| 79 | -- LSP Configuration & Plugins | ||
| 80 | 'neovim/nvim-lspconfig', | 80 | 'neovim/nvim-lspconfig', |
| 81 | dependencies = { | 81 | dependencies = { |
| 82 | -- Automatically install LSPs to stdpath for neovim | 82 | -- Automatically install LSPs to stdpath for neovim |
| @@ -85,25 +85,30 @@ require('lazy').setup({ | |||
| 85 | 85 | ||
| 86 | -- Useful status updates for LSP | 86 | -- Useful status updates for LSP |
| 87 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` | 87 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` |
| 88 | { 'j-hui/fidget.nvim', opts = {} }, | 88 | { 'j-hui/fidget.nvim', opts = {} }, |
| 89 | 89 | ||
| 90 | -- Additional lua configuration, makes nvim stuff amazing! | 90 | -- Additional lua configuration, makes nvim stuff amazing! |
| 91 | 'folke/neodev.nvim', | 91 | 'folke/neodev.nvim', |
| 92 | }, | 92 | }, |
| 93 | }, | 93 | }, |
| 94 | 94 | ||
| 95 | { -- Autocompletion | 95 | { |
| 96 | -- Autocompletion | ||
| 96 | 'hrsh7th/nvim-cmp', | 97 | 'hrsh7th/nvim-cmp', |
| 97 | dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, | 98 | dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, |
| 98 | }, | 99 | }, |
| 99 | 100 | ||
| 100 | -- Useful plugin to show you pending keybinds. | 101 | -- Useful plugin to show you pending keybinds. |
| 101 | { 'folke/which-key.nvim', opts = { | 102 | { |
| 102 | triggers_blacklist = { | 103 | 'folke/which-key.nvim', |
| 103 | n = { ":" }, -- ignore : in normal mode | 104 | opts = { |
| 104 | }, | 105 | triggers_blacklist = { |
| 105 | } }, | 106 | n = { ":" }, -- ignore : in normal mode |
| 106 | { -- Adds git releated signs to the gutter, as well as utilities for managing changes | 107 | }, |
| 108 | } | ||
| 109 | }, | ||
| 110 | { | ||
| 111 | -- Adds git releated signs to the gutter, as well as utilities for managing changes | ||
| 107 | 'lewis6991/gitsigns.nvim', | 112 | 'lewis6991/gitsigns.nvim', |
| 108 | opts = { | 113 | opts = { |
| 109 | -- See `:help gitsigns.txt` | 114 | -- See `:help gitsigns.txt` |
| @@ -117,7 +122,8 @@ require('lazy').setup({ | |||
| 117 | }, | 122 | }, |
| 118 | }, | 123 | }, |
| 119 | 124 | ||
| 120 | { -- Set lualine as statusline | 125 | { |
| 126 | -- Set lualine as statusline | ||
| 121 | 'nvim-lualine/lualine.nvim', | 127 | 'nvim-lualine/lualine.nvim', |
| 122 | -- See `:help lualine.txt` | 128 | -- See `:help lualine.txt` |
| 123 | opts = { | 129 | opts = { |
| @@ -129,7 +135,8 @@ require('lazy').setup({ | |||
| 129 | }, | 135 | }, |
| 130 | }, | 136 | }, |
| 131 | 137 | ||
| 132 | { -- Add indentation guides even on blank lines | 138 | { |
| 139 | -- Add indentation guides even on blank lines | ||
| 133 | 'lukas-reineke/indent-blankline.nvim', | 140 | 'lukas-reineke/indent-blankline.nvim', |
| 134 | -- Enable `lukas-reineke/indent-blankline.nvim` | 141 | -- Enable `lukas-reineke/indent-blankline.nvim` |
| 135 | -- See `:help indent_blankline.txt` | 142 | -- See `:help indent_blankline.txt` |
| @@ -140,14 +147,17 @@ require('lazy').setup({ | |||
| 140 | }, | 147 | }, |
| 141 | 148 | ||
| 142 | -- "gc" to comment visual regions/lines | 149 | -- "gc" to comment visual regions/lines |
| 143 | { 'numToStr/Comment.nvim', opts = { | 150 | { |
| 144 | opleader = { | 151 | 'numToStr/Comment.nvim', |
| 145 | ---Line-comment keymap | 152 | opts = { |
| 146 | line = '<C-_>', | 153 | opleader = { |
| 147 | ---Block-comment keymap | 154 | ---Line-comment keymap |
| 148 | block = 'gb', | 155 | line = '<C-_>', |
| 149 | }, | 156 | ---Block-comment keymap |
| 150 | } }, | 157 | block = 'gb', |
| 158 | }, | ||
| 159 | } | ||
| 160 | }, | ||
| 151 | 161 | ||
| 152 | -- Fuzzy Finder (files, lsp, etc) | 162 | -- Fuzzy Finder (files, lsp, etc) |
| 153 | { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, | 163 | { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, |
| @@ -165,7 +175,8 @@ require('lazy').setup({ | |||
| 165 | end, | 175 | end, |
| 166 | }, | 176 | }, |
| 167 | 177 | ||
| 168 | { -- Highlight, edit, and navigate code | 178 | { |
| 179 | -- Highlight, edit, and navigate code | ||
| 169 | 'nvim-treesitter/nvim-treesitter', | 180 | 'nvim-treesitter/nvim-treesitter', |
| 170 | dependencies = { | 181 | dependencies = { |
| 171 | 'nvim-treesitter/nvim-treesitter-textobjects', | 182 | 'nvim-treesitter/nvim-treesitter-textobjects', |
| @@ -229,6 +240,7 @@ vim.o.completeopt = 'menuone,noselect' | |||
| 229 | -- See more details at https://github.com/neovim/neovim/issues/1716 | 240 | -- See more details at https://github.com/neovim/neovim/issues/1716 |
| 230 | vim.cmd("command! W execute 'SudaWrite %'") | 241 | vim.cmd("command! W execute 'SudaWrite %'") |
| 231 | 242 | ||
| 243 | |||
| 232 | -- [[ Highlight on yank ]] | 244 | -- [[ Highlight on yank ]] |
| 233 | -- See `:help vim.highlight.on_yank()` | 245 | -- See `:help vim.highlight.on_yank()` |
| 234 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) | 246 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) |
| @@ -243,11 +255,11 @@ vim.api.nvim_create_autocmd('TextYankPost', { | |||
| 243 | 255 | ||
| 244 | -- [[ Configure lualine ]] | 256 | -- [[ Configure lualine ]] |
| 245 | -- Change the background of lualine_b section for normal mode | 257 | -- Change the background of lualine_b section for normal mode |
| 246 | local custom_wombat = require'lualine.themes.wombat' | 258 | local custom_wombat = require 'lualine.themes.wombat' |
| 247 | custom_wombat.normal.b.bg = '#a8a8a8' | 259 | custom_wombat.normal.b.bg = '#a8a8a8' |
| 248 | custom_wombat.normal.b.fg = '#444444' | 260 | custom_wombat.normal.b.fg = '#444444' |
| 249 | require('lualine').setup { | 261 | require('lualine').setup { |
| 250 | options = { theme = custom_wombat }, | 262 | options = { theme = custom_wombat }, |
| 251 | } | 263 | } |
| 252 | 264 | ||
| 253 | 265 | ||
| @@ -307,6 +319,7 @@ vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { de | |||
| 307 | vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) | 319 | vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) |
| 308 | vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) | 320 | vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) |
| 309 | 321 | ||
| 322 | |||
| 310 | -- [[ Configure Treesitter ]] | 323 | -- [[ Configure Treesitter ]] |
| 311 | -- See `:help nvim-treesitter` | 324 | -- See `:help nvim-treesitter` |
| 312 | require('nvim-treesitter.configs').setup { | 325 | require('nvim-treesitter.configs').setup { |
| @@ -377,7 +390,7 @@ require('nvim-treesitter.configs').setup { | |||
| 377 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) | 390 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) |
| 378 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) | 391 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) |
| 379 | vim.keymap.set('n', '<leader>E', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) | 392 | vim.keymap.set('n', '<leader>E', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) |
| 380 | -- vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) | 393 | vim.keymap.set('n', '<leader>Q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) |
| 381 | 394 | ||
| 382 | -- LSP settings. | 395 | -- LSP settings. |
| 383 | -- This function gets run when an LSP connects to a particular buffer. | 396 | -- This function gets run when an LSP connects to a particular buffer. |
| @@ -422,6 +435,7 @@ local on_attach = function(_, bufnr) | |||
| 422 | vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) | 435 | vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) |
| 423 | vim.lsp.buf.format() | 436 | vim.lsp.buf.format() |
| 424 | end, { desc = 'Format current buffer with LSP' }) | 437 | end, { desc = 'Format current buffer with LSP' }) |
| 438 | nmap('<leader>F', ':Format<CR>', 'Format code') | ||
| 425 | end | 439 | end |
| 426 | 440 | ||
| 427 | -- Enable the following language servers | 441 | -- Enable the following language servers |