I have joined the dark side! neovim with plugins!
added neovim support for treesitter and LSP, then added a bunch of plugins to take advantage of them.
This commit is contained in:
		
							parent
							
								
									3992946c98
								
							
						
					
					
						commit
						8322dfa4e1
					
				
					 6 changed files with 367 additions and 29 deletions
				
			
		
							
								
								
									
										74
									
								
								neovim/.config/nvim/lua/LSPconfig.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								neovim/.config/nvim/lua/LSPconfig.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,74 @@
 | 
			
		|||
local nvim_lsp = require('lspconfig')
 | 
			
		||||
 | 
			
		||||
-- Use an on_attach function to only map the following keys
 | 
			
		||||
-- after the language server attaches to the current buffer
 | 
			
		||||
local on_attach = function(client, bufnr)
 | 
			
		||||
	local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
 | 
			
		||||
	local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
 | 
			
		||||
 | 
			
		||||
	-- Enable completion triggered by <c-x><c-o>
 | 
			
		||||
	buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
 | 
			
		||||
 | 
			
		||||
	-- Mappings.
 | 
			
		||||
	local opts = { noremap=true, silent=true }
 | 
			
		||||
 | 
			
		||||
	-- See `:help vim.lsp.*` for documentation on any of the below functions
 | 
			
		||||
	buf_set_keymap('', ';lc', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lf', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';li', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';ls', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lwa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lwr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lw', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';la', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lc', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lo', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';ln', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
 | 
			
		||||
	buf_set_keymap('', ';lm', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Use a loop to conveniently call 'setup' on multiple servers and
 | 
			
		||||
-- map buffer local keybindings when the language server attaches
 | 
			
		||||
local servers = { 'pyright', 'rust_analyzer', 'texlab'}
 | 
			
		||||
for _, lsp in ipairs(servers) do
 | 
			
		||||
	nvim_lsp[lsp].setup {
 | 
			
		||||
		flags = {
 | 
			
		||||
			debounce_text_changes = 150,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
on_attach()
 | 
			
		||||
--lua-language-server needs seperate config.
 | 
			
		||||
local runtime_path = vim.split(package.path, ';')
 | 
			
		||||
table.insert(runtime_path, "lua/?.lua")
 | 
			
		||||
table.insert(runtime_path, "lua/?/init.lua")
 | 
			
		||||
require'lspconfig'.sumneko_lua.setup {
 | 
			
		||||
	settings = {
 | 
			
		||||
		Lua = {
 | 
			
		||||
			runtime = {
 | 
			
		||||
				-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
 | 
			
		||||
				version = 'LuaJIT',
 | 
			
		||||
				-- Setup your lua path
 | 
			
		||||
				path = runtime_path,
 | 
			
		||||
			},
 | 
			
		||||
			diagnostics = {
 | 
			
		||||
				-- Get the language server to recognize the `vim` global
 | 
			
		||||
				globals = {'vim'},
 | 
			
		||||
			},
 | 
			
		||||
			workspace = {
 | 
			
		||||
				-- Make the server aware of Neovim runtime files
 | 
			
		||||
				library = vim.api.nvim_get_runtime_file("", true),
 | 
			
		||||
			},
 | 
			
		||||
			-- Do not send telemetry data containing a randomized but unique identifier
 | 
			
		||||
			telemetry = {
 | 
			
		||||
				enable = false,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										68
									
								
								neovim/.config/nvim/lua/cmp-lsp.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								neovim/.config/nvim/lua/cmp-lsp.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,68 @@
 | 
			
		|||
--configure nvim-cmp for use with lsp and luasnip.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Add additional capabilities supported by nvim-cmp
 | 
			
		||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
 | 
			
		||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local lspconfig = require('lspconfig')
 | 
			
		||||
 | 
			
		||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
 | 
			
		||||
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
 | 
			
		||||
for _, lsp in ipairs(servers) do
 | 
			
		||||
	lspconfig[lsp].setup {
 | 
			
		||||
		-- on_attach = my_custom_on_attach,
 | 
			
		||||
		capabilities = capabilities,
 | 
			
		||||
	}
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Set completeopt to have a better completion experience
 | 
			
		||||
vim.o.completeopt = 'menuone,noselect'
 | 
			
		||||
 | 
			
		||||
-- luasnip setup
 | 
			
		||||
local luasnip = require 'luasnip'
 | 
			
		||||
 | 
			
		||||
-- nvim-cmp setup
 | 
			
		||||
local cmp = require 'cmp'
 | 
			
		||||
cmp.setup {
 | 
			
		||||
	snippet = {
 | 
			
		||||
		expand = function(args)
 | 
			
		||||
			require('luasnip').lsp_expand(args.body)
 | 
			
		||||
		end,
 | 
			
		||||
	},
 | 
			
		||||
	mapping = {
 | 
			
		||||
		['<C-p>'] = cmp.mapping.select_prev_item(),
 | 
			
		||||
		['<C-n>'] = cmp.mapping.select_next_item(),
 | 
			
		||||
		['<C-d>'] = cmp.mapping.scroll_docs(-4),
 | 
			
		||||
		['<C-f>'] = cmp.mapping.scroll_docs(4),
 | 
			
		||||
		['<C-Space>'] = cmp.mapping.complete(),
 | 
			
		||||
		['<C-e>'] = cmp.mapping.close(),
 | 
			
		||||
		['<CR>'] = cmp.mapping.confirm {
 | 
			
		||||
			behavior = cmp.ConfirmBehavior.Replace,
 | 
			
		||||
			select = true,
 | 
			
		||||
		},
 | 
			
		||||
		['<Tab>'] = function(fallback)
 | 
			
		||||
			if cmp.visible() then
 | 
			
		||||
				cmp.select_next_item()
 | 
			
		||||
			elseif luasnip.expand_or_jumpable() then
 | 
			
		||||
				luasnip.expand_or_jump()
 | 
			
		||||
			else
 | 
			
		||||
				fallback()
 | 
			
		||||
			end
 | 
			
		||||
		end,
 | 
			
		||||
		['<S-Tab>'] = function(fallback)
 | 
			
		||||
			if cmp.visible() then
 | 
			
		||||
				cmp.select_prev_item()
 | 
			
		||||
			elseif luasnip.jumpable(-1) then
 | 
			
		||||
				luasnip.jump(-1)
 | 
			
		||||
			else
 | 
			
		||||
				fallback()
 | 
			
		||||
			end
 | 
			
		||||
		end,
 | 
			
		||||
	},
 | 
			
		||||
	sources = {
 | 
			
		||||
		{ name = 'nvim_lsp' },
 | 
			
		||||
		{ name = 'luasnip' },
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										170
									
								
								neovim/.config/nvim/lua/packages.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								neovim/.config/nvim/lua/packages.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,170 @@
 | 
			
		|||
-- bootstrapping packer
 | 
			
		||||
local fn=vim.fn
 | 
			
		||||
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
 | 
			
		||||
if fn.empty(fn.glob(install_path)) > 0 then
 | 
			
		||||
	Packer_Bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return require('packer').startup(function(use)
 | 
			
		||||
	use 'wbthomason/packer.nvim'
 | 
			
		||||
 | 
			
		||||
	use {
 | 
			
		||||
		'nvim-treesitter/nvim-treesitter',
 | 
			
		||||
		run = ':TSUpdate'
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use 'neovim/nvim-lspconfig'
 | 
			
		||||
 | 
			
		||||
	use 'yamatsum/nvim-cursorline'
 | 
			
		||||
 | 
			
		||||
	use {'stevearc/dressing.nvim',
 | 
			
		||||
		config=function()
 | 
			
		||||
			require('dressing').setup{}
 | 
			
		||||
		end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'nvim-lualine/lualine.nvim',
 | 
			
		||||
	requires = {'kyazdani42/nvim-web-devicons', opt = true},
 | 
			
		||||
	config=function() require('lualine').setup{
 | 
			
		||||
			options={
 | 
			
		||||
				icons_enabled = true,
 | 
			
		||||
				theme = 'auto',
 | 
			
		||||
				component_separators = { left = '', right = ''},
 | 
			
		||||
				section_separators = { left = '', right = ''},
 | 
			
		||||
				disabled_filetypes = {},
 | 
			
		||||
				always_divide_middle = true,
 | 
			
		||||
			},
 | 
			
		||||
			sections = {
 | 
			
		||||
				lualine_a = {'mode'},
 | 
			
		||||
				lualine_b = {'branch', 'diff', 'diagnostics'},
 | 
			
		||||
				lualine_c = {'filename'},
 | 
			
		||||
				lualine_x = {'encoding', 'fileformat', 'filetype'},
 | 
			
		||||
				lualine_y = {'progress'},
 | 
			
		||||
				lualine_z = {'location'}
 | 
			
		||||
			},
 | 
			
		||||
			inactive_sections = {
 | 
			
		||||
				lualine_a = {},
 | 
			
		||||
				lualine_b = {},
 | 
			
		||||
				lualine_c = {'filename'},
 | 
			
		||||
				lualine_x = {'location'},
 | 
			
		||||
				lualine_y = {},
 | 
			
		||||
				lualine_z = {}
 | 
			
		||||
			},
 | 
			
		||||
			tabline = {},
 | 
			
		||||
			extensions = {}
 | 
			
		||||
		} end,
 | 
			
		||||
	}
 | 
			
		||||
	use {'kdheepak/tabline.nvim',
 | 
			
		||||
		config = function()
 | 
			
		||||
			require'tabline'.setup {
 | 
			
		||||
				-- Defaults configuration options
 | 
			
		||||
				enable = true,
 | 
			
		||||
				options = {
 | 
			
		||||
					-- If lualine is installed tabline will use separators configured in lualine by default.
 | 
			
		||||
					-- These options can be used to override those settings.
 | 
			
		||||
					-- section_separators = {'', ''},
 | 
			
		||||
					-- component_separators = {'', ''},
 | 
			
		||||
					-- max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3
 | 
			
		||||
					show_tabs_always = false, -- this shows tabs only when there are more than one tab or if the first tab is named
 | 
			
		||||
					show_devicons = true, -- this shows devicons in buffer section
 | 
			
		||||
					show_bufnr = true, -- this appends [bufnr] to buffer section,
 | 
			
		||||
					show_filename_only = false, -- shows base filename only instead of relative path in filename
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			vim.cmd[[
 | 
			
		||||
			set guioptions-=e " Use showtabline in gui vim
 | 
			
		||||
			set sessionoptions+=tabpages,globals " store tabpages and globals in session
 | 
			
		||||
			]]
 | 
			
		||||
		end,
 | 
			
		||||
		requires = { { 'hoob3rt/lualine.nvim', opt=true }, {'kyazdani42/nvim-web-devicons', opt = true} }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	use {'numToStr/Comment.nvim',
 | 
			
		||||
		config = function()
 | 
			
		||||
			require('Comment').setup()
 | 
			
		||||
		end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'hrsh7th/nvim-cmp',
 | 
			
		||||
		requires = {
 | 
			
		||||
			-- 'neovim/nvim-lspconfig',
 | 
			
		||||
			'hrsh7th/cmp-nvim-lsp',
 | 
			
		||||
			'saadparwaiz1/cmp_luasnip',
 | 
			
		||||
			'L3MON4D3/LuaSnip'
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'folke/todo-comments.nvim',
 | 
			
		||||
		requires = 'nvim-lua/plenary.nvim',
 | 
			
		||||
		config = function()
 | 
			
		||||
			require('todo-comments').setup()
 | 
			
		||||
		end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'nvim-telescope/telescope.nvim',
 | 
			
		||||
		requires = {
 | 
			
		||||
			{'nvim-lua/plenary.nvim'},
 | 
			
		||||
			{'nvim-lua/popup.nvim'},
 | 
			
		||||
			{'nvim-treesitter/nvim-treesitter'},
 | 
			
		||||
			{'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
 | 
			
		||||
			{'nvim-telescope/telescope-symbols.nvim'},
 | 
			
		||||
		},
 | 
			
		||||
		config=function()
 | 
			
		||||
			require'telescope'.load_extension('fzf')
 | 
			
		||||
		end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'Shatur/neovim-session-manager',
 | 
			
		||||
		requires = 'nvim-telescope/telescope.nvim',
 | 
			
		||||
		config = function()
 | 
			
		||||
			require('telescope').load_extension('sessions')
 | 
			
		||||
		end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'romgrk/nvim-treesitter-context',
 | 
			
		||||
		requires = 'nvim-treesitter/nvim-treesitter',
 | 
			
		||||
		config=function() require('treesitter-context').setup() end,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'kyazdani42/nvim-tree.lua',
 | 
			
		||||
		requires = {
 | 
			
		||||
		  'kyazdani42/nvim-web-devicons', -- optional, for file icon
 | 
			
		||||
		},
 | 
			
		||||
		config = function() require'nvim-tree'.setup {} end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'lewis6991/gitsigns.nvim',
 | 
			
		||||
		requires = {'nvim-lua/plenary.nvim'},
 | 
			
		||||
		tag = 'release', -- To use the latest release
 | 
			
		||||
		config=function() require('gitsigns').setup() end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use 'chentau/marks.nvim'
 | 
			
		||||
 | 
			
		||||
	use 'tversteeg/registers.nvim'
 | 
			
		||||
 | 
			
		||||
	use {
 | 
			
		||||
		'sudormrfbin/cheatsheet.nvim',
 | 
			
		||||
 | 
			
		||||
		requires = {
 | 
			
		||||
			{'nvim-telescope/telescope.nvim'},
 | 
			
		||||
			{'nvim-lua/popup.nvim'},
 | 
			
		||||
			{'nvim-lua/plenary.nvim'},
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use {'lewis6991/spellsitter.nvim',
 | 
			
		||||
		config=function() require('spellsitter').setup() end
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	use 'lukas-reineke/indent-blankline.nvim'
 | 
			
		||||
 | 
			
		||||
	use 'bluz71/vim-moonfly-colors'
 | 
			
		||||
 | 
			
		||||
	use 'bluz71/vim-nightfly-guicolors'
 | 
			
		||||
 | 
			
		||||
	if Packer_Bootstrap then
 | 
			
		||||
		require('packer').sync()
 | 
			
		||||
	end
 | 
			
		||||
end)
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue