adding additional plugins
This commit is contained in:
		
							parent
							
								
									723a3213d4
								
							
						
					
					
						commit
						7b00b4cf60
					
				
							
								
								
									
										208
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										208
									
								
								init.lua
								
								
								
								
							|  | @ -1,43 +1,3 @@ | ||||||
| --[[ |  | ||||||
| 
 |  | ||||||
| ===================================================================== |  | ||||||
| ==================== READ THIS BEFORE CONTINUING ==================== |  | ||||||
| ===================================================================== |  | ||||||
| 
 |  | ||||||
| Kickstart.nvim is *not* a distribution. |  | ||||||
| 
 |  | ||||||
| Kickstart.nvim is a template for your own configuration. |  | ||||||
|   The goal is that you can read every line of code, top-to-bottom, understand |  | ||||||
|   what your configuration is doing, and modify it to suit your needs. |  | ||||||
| 
 |  | ||||||
|   Once you've done that, you should start exploring, configuring and tinkering to |  | ||||||
|   explore Neovim! |  | ||||||
| 
 |  | ||||||
|   If you don't know anything about Lua, I recommend taking some time to read through |  | ||||||
|   a guide. One possible example: |  | ||||||
|   - https://learnxinyminutes.com/docs/lua/ |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|   And then you can explore or search through `:help lua-guide` |  | ||||||
|   - https://neovim.io/doc/user/lua-guide.html |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| Kickstart Guide: |  | ||||||
| 
 |  | ||||||
| I have left several `:help X` comments throughout the init.lua |  | ||||||
| You should run that command and read that help section for more information. |  | ||||||
| 
 |  | ||||||
| In addition, I have some `NOTE:` items throughout the file. |  | ||||||
| These are for you, the reader to help understand what is happening. Feel free to delete |  | ||||||
| them once you know what you're doing, but they should serve as a guide for when you |  | ||||||
| are first encountering a few different constructs in your nvim config. |  | ||||||
| 
 |  | ||||||
| I hope you enjoy your Neovim journey, |  | ||||||
| - TJ |  | ||||||
| 
 |  | ||||||
| P.S. You can delete this when you're done too. It's your config now :) |  | ||||||
| --]] |  | ||||||
| 
 |  | ||||||
| -- Set <space> as the leader key | -- Set <space> as the leader key | ||||||
| -- See `:help mapleader` | -- See `:help mapleader` | ||||||
| --  NOTE: Must happen before plugins are required (otherwise wrong leader will be used) | --  NOTE: Must happen before plugins are required (otherwise wrong leader will be used) | ||||||
|  | @ -214,27 +174,6 @@ require('lazy').setup({ | ||||||
|   -- "gc" to comment visual regions/lines |   -- "gc" to comment visual regions/lines | ||||||
|   { 'numToStr/Comment.nvim', opts = {} }, |   { 'numToStr/Comment.nvim', opts = {} }, | ||||||
| 
 | 
 | ||||||
|   -- Fuzzy Finder (files, lsp, etc) |  | ||||||
|   { |  | ||||||
|     'nvim-telescope/telescope.nvim', |  | ||||||
|     branch = '0.1.x', |  | ||||||
|     dependencies = { |  | ||||||
|       'nvim-lua/plenary.nvim', |  | ||||||
|       -- Fuzzy Finder Algorithm which requires local dependencies to be built. |  | ||||||
|       -- Only load if `make` is available. Make sure you have the system |  | ||||||
|       -- requirements installed. |  | ||||||
|       { |  | ||||||
|         'nvim-telescope/telescope-fzf-native.nvim', |  | ||||||
|         -- NOTE: If you are having trouble with this installation, |  | ||||||
|         --       refer to the README for telescope-fzf-native for more instructions. |  | ||||||
|         build = 'make', |  | ||||||
|         cond = function() |  | ||||||
|           return vim.fn.executable 'make' == 1 |  | ||||||
|         end, |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   { |   { | ||||||
|     -- Highlight, edit, and navigate code |     -- Highlight, edit, and navigate code | ||||||
|     'nvim-treesitter/nvim-treesitter', |     'nvim-treesitter/nvim-treesitter', | ||||||
|  | @ -272,153 +211,6 @@ require('lazy').setup({ | ||||||
| 
 | 
 | ||||||
| -- NeoTree Settings | -- NeoTree Settings | ||||||
| vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left<cr>') | vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left<cr>') | ||||||
| -- [[ Setting options ]] |  | ||||||
| -- See `:help vim.o` |  | ||||||
| -- NOTE: You can change these options as you wish! |  | ||||||
| 
 |  | ||||||
| -- Set highlight on search |  | ||||||
| vim.o.hlsearch = false |  | ||||||
| 
 |  | ||||||
| -- Make line numbers default |  | ||||||
| vim.wo.number = true |  | ||||||
| 
 |  | ||||||
| -- Enable mouse mode |  | ||||||
| vim.o.mouse = 'a' |  | ||||||
| 
 |  | ||||||
| -- Sync clipboard between OS and Neovim. |  | ||||||
| --  Remove this option if you want your OS clipboard to remain independent. |  | ||||||
| --  See `:help 'clipboard'` |  | ||||||
| vim.o.clipboard = 'unnamedplus' |  | ||||||
| 
 |  | ||||||
| -- Enable break indent |  | ||||||
| vim.o.breakindent = true |  | ||||||
| 
 |  | ||||||
| -- Save undo history |  | ||||||
| vim.o.undofile = true |  | ||||||
| 
 |  | ||||||
| -- Case-insensitive searching UNLESS \C or capital in search |  | ||||||
| vim.o.ignorecase = true |  | ||||||
| vim.o.smartcase = true |  | ||||||
| 
 |  | ||||||
| -- Keep signcolumn on by default |  | ||||||
| vim.wo.signcolumn = 'yes' |  | ||||||
| 
 |  | ||||||
| -- Decrease update time |  | ||||||
| vim.o.updatetime = 250 |  | ||||||
| vim.o.timeoutlen = 300 |  | ||||||
| 
 |  | ||||||
| -- Set completeopt to have a better completion experience |  | ||||||
| vim.o.completeopt = 'menuone,noselect' |  | ||||||
| 
 |  | ||||||
| -- NOTE: You should make sure your terminal supports this |  | ||||||
| vim.o.termguicolors = true |  | ||||||
| 
 |  | ||||||
| -- [[ Basic Keymaps ]] |  | ||||||
| 
 |  | ||||||
| -- Keymaps for better default experience |  | ||||||
| -- See `:help vim.keymap.set()` |  | ||||||
| vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) |  | ||||||
| 
 |  | ||||||
| -- Remap for dealing with word wrap |  | ||||||
| vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) |  | ||||||
| vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) |  | ||||||
| 
 |  | ||||||
| -- Diagnostic keymaps |  | ||||||
| vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) |  | ||||||
| vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) |  | ||||||
| vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) |  | ||||||
| vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) |  | ||||||
| 
 |  | ||||||
| -- [[ Highlight on yank ]] |  | ||||||
| -- See `:help vim.highlight.on_yank()` |  | ||||||
| local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) |  | ||||||
| vim.api.nvim_create_autocmd('TextYankPost', { |  | ||||||
|   callback = function() |  | ||||||
|     vim.highlight.on_yank() |  | ||||||
|   end, |  | ||||||
|   group = highlight_group, |  | ||||||
|   pattern = '*', |  | ||||||
| }) |  | ||||||
| 
 |  | ||||||
| -- [[ Configure Telescope ]] |  | ||||||
| -- See `:help telescope` and `:help telescope.setup()` |  | ||||||
| require('telescope').setup { |  | ||||||
|   defaults = { |  | ||||||
|     mappings = { |  | ||||||
|       i = { |  | ||||||
|         ['<C-u>'] = false, |  | ||||||
|         ['<C-d>'] = false, |  | ||||||
|       }, |  | ||||||
|     }, |  | ||||||
|   }, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| -- Enable telescope fzf native, if installed |  | ||||||
| pcall(require('telescope').load_extension, 'fzf') |  | ||||||
| 
 |  | ||||||
| -- Telescope live_grep in git root |  | ||||||
| -- Function to find the git root directory based on the current buffer's path |  | ||||||
| local function find_git_root() |  | ||||||
|   -- Use the current buffer's path as the starting point for the git search |  | ||||||
|   local current_file = vim.api.nvim_buf_get_name(0) |  | ||||||
|   local current_dir |  | ||||||
|   local cwd = vim.fn.getcwd() |  | ||||||
|   -- If the buffer is not associated with a file, return nil |  | ||||||
|   if current_file == '' then |  | ||||||
|     current_dir = cwd |  | ||||||
|   else |  | ||||||
|     -- Extract the directory from the current file's path |  | ||||||
|     current_dir = vim.fn.fnamemodify(current_file, ':h') |  | ||||||
|   end |  | ||||||
| 
 |  | ||||||
|   -- Find the Git root directory from the current file's path |  | ||||||
|   local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] |  | ||||||
|   if vim.v.shell_error ~= 0 then |  | ||||||
|     print 'Not a git repository. Searching on current working directory' |  | ||||||
|     return cwd |  | ||||||
|   end |  | ||||||
|   return git_root |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- Custom live_grep function to search in git root |  | ||||||
| local function live_grep_git_root() |  | ||||||
|   local git_root = find_git_root() |  | ||||||
|   if git_root then |  | ||||||
|     require('telescope.builtin').live_grep { |  | ||||||
|       search_dirs = { git_root }, |  | ||||||
|     } |  | ||||||
|   end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) |  | ||||||
| 
 |  | ||||||
| -- See `:help telescope.builtin` |  | ||||||
| vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) |  | ||||||
| vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) |  | ||||||
| vim.keymap.set('n', '<leader>/', function() |  | ||||||
|   -- You can pass additional configuration to telescope to change theme, layout, etc. |  | ||||||
|   require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { |  | ||||||
|     winblend = 10, |  | ||||||
|     previewer = false, |  | ||||||
|   }) |  | ||||||
| end, { desc = '[/] Fuzzily search in current buffer' }) |  | ||||||
| 
 |  | ||||||
| local function telescope_live_grep_open_files() |  | ||||||
|   require('telescope.builtin').live_grep { |  | ||||||
|     grep_open_files = true, |  | ||||||
|     prompt_title = 'Live Grep in Open Files', |  | ||||||
|   } |  | ||||||
| end |  | ||||||
| vim.keymap.set('n', '<leader>s/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) |  | ||||||
| vim.keymap.set('n', '<leader>ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) |  | ||||||
| vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) |  | ||||||
| vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) |  | ||||||
| vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) |  | ||||||
| vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) |  | ||||||
| vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) |  | ||||||
| vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' }) |  | ||||||
| vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) |  | ||||||
| vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) |  | ||||||
| 
 | 
 | ||||||
| -- [[ Configure Treesitter ]] | -- [[ Configure Treesitter ]] | ||||||
| -- See `:help nvim-treesitter` | -- See `:help nvim-treesitter` | ||||||
|  |  | ||||||
|  | @ -0,0 +1,39 @@ | ||||||
|  | -- [[ Setting options ]] | ||||||
|  | -- See `:help vim.o` | ||||||
|  | 
 | ||||||
|  | -- Set highlight on search | ||||||
|  | vim.o.hlsearch = false | ||||||
|  | 
 | ||||||
|  | -- Make line numbers default | ||||||
|  | vim.wo.number = true | ||||||
|  | 
 | ||||||
|  | -- Enable mouse mode | ||||||
|  | vim.o.mouse = 'a' | ||||||
|  | 
 | ||||||
|  | -- Sync clipboard between OS and Neovim. | ||||||
|  | --  Remove this option if you want your OS clipboard to remain independent. | ||||||
|  | --  See `:help 'clipboard'` | ||||||
|  | vim.o.clipboard = 'unnamedplus' | ||||||
|  | 
 | ||||||
|  | -- Enable break indent | ||||||
|  | vim.o.breakindent = true | ||||||
|  | 
 | ||||||
|  | -- Save undo history | ||||||
|  | vim.o.undofile = true | ||||||
|  | 
 | ||||||
|  | -- Case-insensitive searching UNLESS \C or capital in search | ||||||
|  | vim.o.ignorecase = true | ||||||
|  | vim.o.smartcase = true | ||||||
|  | 
 | ||||||
|  | -- Keep signcolumn on by default | ||||||
|  | vim.wo.signcolumn = 'yes' | ||||||
|  | 
 | ||||||
|  | -- Decrease update time | ||||||
|  | vim.o.updatetime = 250 | ||||||
|  | vim.o.timeoutlen = 300 | ||||||
|  | 
 | ||||||
|  | -- Set completeopt to have a better completion experience | ||||||
|  | vim.o.completeopt = 'menuone,noselect' | ||||||
|  | 
 | ||||||
|  | -- NOTE: You should make sure your terminal supports this | ||||||
|  | vim.o.termguicolors = true | ||||||
|  | @ -0,0 +1,103 @@ | ||||||
|  | -- Fuzzy Finder (files, lsp, etc) | ||||||
|  | return { | ||||||
|  | 	'nvim-telescope/telescope.nvim', | ||||||
|  | 	branch = '0.1.x', | ||||||
|  | 	dependencies = { | ||||||
|  | 		'nvim-lua/plenary.nvim', | ||||||
|  | 		-- Fuzzy Finder Algorithm which requires local dependencies to be built. | ||||||
|  | 		-- Only load if `make` is available. Make sure you have the system | ||||||
|  | 		-- requirements installed. | ||||||
|  | 		{ | ||||||
|  | 			'nvim-telescope/telescope-fzf-native.nvim', | ||||||
|  | 			-- NOTE: If you are having trouble with this installation, | ||||||
|  | 			--       refer to the README for telescope-fzf-native for more instructions. | ||||||
|  | 			build = 'make', | ||||||
|  | 			cond = function() | ||||||
|  | 				return vim.fn.executable 'make' == 1 | ||||||
|  | 			end, | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	config = function() | ||||||
|  | 		efaults = { | ||||||
|  | 			    mappings = { | ||||||
|  | 				    i = { | ||||||
|  | 					    ['<C-u>'] = false, | ||||||
|  | 					    ['<C-d>'] = false, | ||||||
|  | 				    }, | ||||||
|  | 			    }, | ||||||
|  | 		    }, | ||||||
|  | 		    -- Enable telescope fzf native, if installed | ||||||
|  | 		    pcall(require('telescope').load_extension, 'fzf') | ||||||
|  | 
 | ||||||
|  | 		-- Telescope live_grep in git root | ||||||
|  | 		-- Function to find the git root directory based on the current buffer's path | ||||||
|  | 		local function find_git_root() | ||||||
|  | 			-- Use the current buffer's path as the starting point for the git search | ||||||
|  | 			local current_file = vim.api.nvim_buf_get_name(0) | ||||||
|  | 			local current_dir | ||||||
|  | 			local cwd = vim.fn.getcwd() | ||||||
|  | 			-- If the buffer is not associated with a file, return nil | ||||||
|  | 			if current_file == '' then | ||||||
|  | 				current_dir = cwd | ||||||
|  | 			else | ||||||
|  | 				-- Extract the directory from the current file's path | ||||||
|  | 				current_dir = vim.fn.fnamemodify(current_file, ':h') | ||||||
|  | 			end | ||||||
|  | 
 | ||||||
|  | 			-- Find the Git root directory from the current file's path | ||||||
|  | 			local git_root = vim.fn.systemlist('git -C ' .. | ||||||
|  | 			vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] | ||||||
|  | 			if vim.v.shell_error ~= 0 then | ||||||
|  | 				print 'Not a git repository. Searching on current working directory' | ||||||
|  | 				return cwd | ||||||
|  | 			end | ||||||
|  | 			return git_root | ||||||
|  | 		end | ||||||
|  | 
 | ||||||
|  | 		-- Custom live_grep function to search in git root | ||||||
|  | 		local function live_grep_git_root() | ||||||
|  | 			local git_root = find_git_root() | ||||||
|  | 			if git_root then | ||||||
|  | 				require('telescope.builtin').live_grep { | ||||||
|  | 					search_dirs = { git_root }, | ||||||
|  | 				} | ||||||
|  | 			end | ||||||
|  | 		end | ||||||
|  | 
 | ||||||
|  | 		vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) | ||||||
|  | 
 | ||||||
|  | 		-- See `:help telescope.builtin` | ||||||
|  | 		vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, | ||||||
|  | 			{ desc = '[?] Find recently opened files' }) | ||||||
|  | 		vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, | ||||||
|  | 			{ desc = '[ ] Find existing buffers' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>/', function() | ||||||
|  | 			-- You can pass additional configuration to telescope to change theme, layout, etc. | ||||||
|  | 			require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { | ||||||
|  | 				winblend = 10, | ||||||
|  | 				previewer = false, | ||||||
|  | 			}) | ||||||
|  | 		end, { desc = '[/] Fuzzily search in current buffer' }) | ||||||
|  | 
 | ||||||
|  | 		local function telescope_live_grep_open_files() | ||||||
|  | 			require('telescope.builtin').live_grep { | ||||||
|  | 				grep_open_files = true, | ||||||
|  | 				prompt_title = 'Live Grep in Open Files', | ||||||
|  | 			} | ||||||
|  | 		end | ||||||
|  | 		vim.keymap.set('n', '<leader>s/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>ss', require('telescope.builtin').builtin, | ||||||
|  | 			{ desc = '[S]earch [S]elect Telescope' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, | ||||||
|  | 			{ desc = 'Search [G]it [F]iles' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, | ||||||
|  | 			{ desc = '[S]earch current [W]ord' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, | ||||||
|  | 			{ desc = '[S]earch [D]iagnostics' }) | ||||||
|  | 		vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) | ||||||
|  | 	end | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue