lazy.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. -- [[ Install `lazy.nvim` plugin manager ]]
  2. -- https://github.com/folke/lazy.nvim
  3. -- `:help lazy.nvim.txt` for more info
  4. local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
  5. if not vim.loop.fs_stat(lazypath) then
  6. vim.fn.system {
  7. 'git',
  8. 'clone',
  9. '--filter=blob:none',
  10. 'https://github.com/folke/lazy.nvim.git',
  11. '--branch=stable', -- latest stable release
  12. lazypath,
  13. }
  14. end
  15. vim.opt.rtp:prepend(lazypath)
  16. -- [[ Configure plugins ]]
  17. -- NOTE: Here is where you install your plugins.
  18. -- You can configure plugins using the `config` key.
  19. --
  20. -- You can also configure plugins after the setup call,
  21. -- as they will be available in your neovim runtime.
  22. require('lazy').setup({
  23. -- NOTE: First, some plugins that don't require any configuration
  24. -- Git related plugins
  25. 'tpope/vim-fugitive',
  26. 'tpope/vim-rhubarb',
  27. -- Detect tabstop and shiftwidth automatically
  28. 'tpope/vim-sleuth',
  29. -- Autoformat on save
  30. 'jose-elias-alvarez/null-ls.nvim',
  31. {
  32. "kdheepak/lazygit.nvim",
  33. -- optional for floating window border decoration
  34. dependencies = {
  35. "nvim-lua/plenary.nvim",
  36. },
  37. },
  38. -- When life gets too hard
  39. 'eandrju/cellular-automaton.nvim',
  40. 'leafOfTree/vim-svelte-plugin',
  41. -- NOTE: This is where your plugins related to LSP can be installed.
  42. -- The configuration is done below. Search for lspconfig to find it below.
  43. {
  44. -- LSP Configuration & Plugins
  45. 'neovim/nvim-lspconfig',
  46. dependencies = {
  47. -- Automatically install LSPs to stdpath for neovim
  48. { 'williamboman/mason.nvim', config = true },
  49. 'williamboman/mason-lspconfig.nvim',
  50. -- Useful status updates for LSP
  51. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
  52. { 'j-hui/fidget.nvim', opts = {} },
  53. -- Additional lua configuration, makes nvim stuff amazing!
  54. 'folke/neodev.nvim',
  55. },
  56. },
  57. {
  58. -- Autocompletion
  59. 'hrsh7th/nvim-cmp',
  60. dependencies = {
  61. -- Snippet Engine & its associated nvim-cmp source
  62. {
  63. 'L3MON4D3/LuaSnip',
  64. build = (function()
  65. -- Build Step is needed for regex support in snippets
  66. -- This step is not supported in many windows environments
  67. -- Remove the below condition to re-enable on windows
  68. if vim.fn.has 'win32' == 1 then
  69. return
  70. end
  71. return 'make install_jsregexp'
  72. end)(),
  73. },
  74. 'saadparwaiz1/cmp_luasnip',
  75. -- Adds LSP completion capabilities
  76. 'hrsh7th/cmp-nvim-lsp',
  77. 'hrsh7th/cmp-path',
  78. -- Adds a number of user-friendly snippets
  79. 'rafamadriz/friendly-snippets',
  80. },
  81. },
  82. -- Useful plugin to show you pending keybinds.
  83. { 'folke/which-key.nvim', opts = {} },
  84. {
  85. -- Adds git related signs to the gutter, as well as utilities for managing changes
  86. 'lewis6991/gitsigns.nvim',
  87. opts = {
  88. -- See `:help gitsigns.txt`
  89. signs = {
  90. add = { text = '+' },
  91. change = { text = '~' },
  92. delete = { text = '_' },
  93. topdelete = { text = '‾' },
  94. changedelete = { text = '~' },
  95. },
  96. on_attach = function(bufnr)
  97. local gs = package.loaded.gitsigns
  98. local function map(mode, l, r, opts)
  99. opts = opts or {}
  100. opts.buffer = bufnr
  101. vim.keymap.set(mode, l, r, opts)
  102. end
  103. -- Navigation
  104. map({ 'n', 'v' }, ']c', function()
  105. if vim.wo.diff then
  106. return ']c'
  107. end
  108. vim.schedule(function()
  109. gs.next_hunk()
  110. end)
  111. return '<Ignore>'
  112. end, { expr = true, desc = 'Jump to next hunk' })
  113. map({ 'n', 'v' }, '[c', function()
  114. if vim.wo.diff then
  115. return '[c'
  116. end
  117. vim.schedule(function()
  118. gs.prev_hunk()
  119. end)
  120. return '<Ignore>'
  121. end, { expr = true, desc = 'Jump to previous hunk' })
  122. -- Actions
  123. -- visual mode
  124. map('v', '<leader>hs', function()
  125. gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
  126. end, { desc = 'stage git hunk' })
  127. map('v', '<leader>hr', function()
  128. gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
  129. end, { desc = 'reset git hunk' })
  130. -- normal mode
  131. map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
  132. map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
  133. map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
  134. map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
  135. map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
  136. map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
  137. map('n', '<leader>hb', function()
  138. gs.blame_line { full = false }
  139. end, { desc = 'git blame line' })
  140. map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
  141. map('n', '<leader>hD', function()
  142. gs.diffthis '~'
  143. end, { desc = 'git diff against last commit' })
  144. -- Toggles
  145. map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
  146. map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
  147. -- Text object
  148. map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
  149. end,
  150. },
  151. },
  152. {
  153. "folke/tokyonight.nvim",
  154. lazy = false,
  155. priority = 1000,
  156. config = function()
  157. require('tokyonight').setup {
  158. style = 'night'
  159. }
  160. end
  161. },
  162. {
  163. -- Theme inspired by Atom
  164. 'navarasu/onedark.nvim',
  165. lazy = false,
  166. priority = 0,
  167. config = function()
  168. require('onedark').setup {
  169. -- Set a style preset. 'dark' is default.
  170. style = 'dark', -- dark, darker, cool, deep, warm, warmer, light
  171. }
  172. require('onedark').load()
  173. end,
  174. },
  175. {
  176. -- Set lualine as statusline
  177. 'nvim-lualine/lualine.nvim',
  178. -- See `:help lualine.txt`
  179. opts = {
  180. options = {
  181. icons_enabled = true,
  182. theme = 'tokyonight',
  183. component_separators = '|',
  184. section_separators = '',
  185. },
  186. },
  187. },
  188. {
  189. -- Add indentation guides even on blank lines
  190. 'lukas-reineke/indent-blankline.nvim',
  191. -- Enable `lukas-reineke/indent-blankline.nvim`
  192. -- See `:help ibl`
  193. main = 'ibl',
  194. opts = {
  195. indent = {
  196. char = '▏',
  197. }
  198. }
  199. },
  200. -- "gc" to comment visual regions/lines
  201. { 'numToStr/Comment.nvim', opts = {} },
  202. -- Fuzzy Finder (files, lsp, etc)
  203. {
  204. 'nvim-telescope/telescope.nvim',
  205. branch = '0.1.x',
  206. dependencies = {
  207. 'nvim-lua/plenary.nvim',
  208. -- Fuzzy Finder Algorithm which requires local dependencies to be built.
  209. -- Only load if `make` is available. Make sure you have the system
  210. -- requirements installed.
  211. {
  212. 'nvim-telescope/telescope-fzf-native.nvim',
  213. -- NOTE: If you are having trouble with this installation,
  214. -- refer to the README for telescope-fzf-native for more instructions.
  215. build = 'make',
  216. cond = function()
  217. return vim.fn.executable 'make' == 1
  218. end,
  219. },
  220. },
  221. },
  222. {
  223. -- Highlight, edit, and navigate code
  224. 'nvim-treesitter/nvim-treesitter',
  225. dependencies = {
  226. 'nvim-treesitter/nvim-treesitter-textobjects',
  227. },
  228. build = ':TSUpdate',
  229. },
  230. {
  231. 'rust-lang/rust.vim',
  232. ft = 'rust',
  233. init = function()
  234. vim.g.rustfmt_autosave = 1
  235. end
  236. },
  237. -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
  238. -- These are some example plugins that I've included in the kickstart repository.
  239. -- Uncomment any of the lines below to enable them.
  240. -- require 'kickstart.plugins.autoformat',
  241. require 'kickstart.plugins.debug',
  242. -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
  243. -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
  244. -- up-to-date with whatever is in the kickstart repo.
  245. -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
  246. --
  247. -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
  248. -- { import = 'custom.plugins' },
  249. }, {})