update init.lua to match upstream

pull/382/head
nathan 2 years ago
parent 7e3914a422
commit b8f76b632c

@ -1,199 +1,191 @@
-- Install packer --[[
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
local is_bootstrap = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
is_bootstrap = true
vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }
vim.cmd [[packadd packer.nvim]]
end
require('packer').startup(function(use) =====================================================================
-- Package manager ==================== READ THIS BEFORE CONTINUING ====================
use 'wbthomason/packer.nvim' =====================================================================
use { -- LSP Configuration & Plugins Kickstart.nvim is *not* a distribution.
'neovim/nvim-lspconfig',
requires = {
-- Automatically install LSPs to stdpath for neovim
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP Kickstart.nvim is a template for your own configuration.
'j-hui/fidget.nvim', The goal is that you can read every line of code, top-to-bottom, and understand
what your configuration is doing.
-- Additional lua configuration, makes nvim stuff amazing Once you've done that, you should start exploring, configuring and tinkering to
'folke/neodev.nvim', explore Neovim!
},
}
use { -- Autocompletion If you don't know anything about Lua, I recommend taking some time to read through
'hrsh7th/nvim-cmp', a guide. One possible example:
requires = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, - https://learnxinyminutes.com/docs/lua/
}
use { -- Highlight, edit, and navigate code And then you can explore or search through `:help lua-guide`
'nvim-treesitter/nvim-treesitter',
run = function()
pcall(require('nvim-treesitter.install').update { with_sync = true })
end,
}
use { -- Additional text objects via treesitter
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter',
}
-- Git related plugins Kickstart Guide:
use 'tpope/vim-fugitive'
use 'tpope/vim-rhubarb'
use 'lewis6991/gitsigns.nvim'
use 'navarasu/onedark.nvim' -- Theme inspired by Atom I have left several `:help X` comments throughout the init.lua
use 'nvim-lualine/lualine.nvim' -- Fancier statusline You should run that command and read that help section for more information.
use 'lukas-reineke/indent-blankline.nvim' -- Add indentation guides even on blank lines
use 'numToStr/Comment.nvim' -- "gc" to comment visual regions/lines
use 'tpope/vim-sleuth' -- Detect tabstop and shiftwidth automatically
-- Fuzzy Finder (files, lsp, etc) In addition, I have some `NOTE:` items throughout the file.
use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } 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.
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available I hope you enjoy your Neovim journey,
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable 'make' == 1 } - TJ
P.S. You can delete this when you're done too. It's your config now :)
--]]
-- User Defined -- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Leap to help quickly navigate -- Install package manager
-- https://github.com/folke/lazy.nvim
-- `:help lazy.nvim.txt` for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)
use 'ggandor/leap.nvim' -- NOTE: Here is where you install your plugins.
-- You can configure plugins using the `config` key.
--
-- You can also configure plugins after the setup call,
-- as they will be available in your neovim runtime.
require('lazy').setup({
-- NOTE: First, some plugins that don't require any configuration
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
-- Adds ability to highlight row and/or column containing cursor -- Detect tabstop and shiftwidth automatically
use { 'tpope/vim-sleuth',
'tummetott/reticle.nvim',
config = function()
require('reticle').setup {
-- add options here or leave empty -- NOTE: This is where your plugins related to LSP can be installed.
} -- The configuration is done below. Search for lspconfig to find it below.
end { -- LSP Configuration & Plugins
} 'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ 'williamboman/mason.nvim', config = true },
'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim',
},
},
{ -- Autocompletion
'hrsh7th/nvim-cmp',
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
},
-- Shows what actions can be performed by pressing keys -- Useful plugin to show you pending keybinds.
use { { 'folke/which-key.nvim', opts = {} },
"folke/which-key.nvim", { -- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
},
},
{ -- Theme inspired by Atom
'navarasu/onedark.nvim',
priority = 1000,
config = function() config = function()
vim.o.timeout = true vim.cmd.colorscheme 'onedark'
vim.o.timeoutlen = 300 end,
require("which-key").setup { },
{
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
spelling = {
enabled = false, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
},
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
motions = true, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true, -- bindings for prefixed with g
},
},
-- add operators that will trigger motion and text object completion
-- to enable all native operators, set the preset / operators plugin above
operators = { gc = "Comments" },
key_labels = {
-- override the label used to display some keys. It doesn't effect WK in any other way.
-- For example:
-- ["<space>"] = "SPC",
-- ["<cr>"] = "RET",
-- ["<tab>"] = "TAB",
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+", -- symbol prepended to a group
},
popup_mappings = {
scroll_down = '<c-d>', -- binding to scroll down inside the popup
scroll_up = '<c-u>', -- binding to scroll up inside the popup
},
window = {
border = "none", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0
},
layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
align = "left", -- align columns left, center or right
},
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible
show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specify a list manually
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
-- this is mostly relevant for key maps that start with a native binding
-- most people should not need to change this
i = { "j", "k" },
v = { "j", "k" },
},
-- disable the WhichKey popup for certain buf types and file types.
-- Disabled by deafult for Telescope
disable = {
buftypes = {},
filetypes = { "TelescopePrompt" },
},
}
}
end
}
{ -- Set lualine as statusline
'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = false,
theme = 'onedark',
component_separators = '|',
section_separators = '',
},
},
},
-- Add custom plugins to packer from ~/.config/nvim/lua/custom/plugins.lua { -- Add indentation guides even on blank lines
local has_plugins, plugins = pcall(require, 'custom.plugins') 'lukas-reineke/indent-blankline.nvim',
if has_plugins then -- Enable `lukas-reineke/indent-blankline.nvim`
plugins(use) -- See `:help indent_blankline.txt`
end opts = {
char = '',
show_trailing_blankline_indent = false,
},
},
if is_bootstrap then -- "gc" to comment visual regions/lines
require('packer').sync() { 'numToStr/Comment.nvim', opts = {} },
end
end)
-- When we are bootstrapping a configuration, it doesn't -- Fuzzy Finder (files, lsp, etc)
-- make sense to execute the rest of the init.lua. { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } },
--
-- You'll need to restart nvim, and then it will work. -- Fuzzy Finder Algorithm which requires local dependencies to be built.
if is_bootstrap then -- Only load if `make` is available. Make sure you have the system
print '==================================' -- requirements installed.
print ' Plugins are being installed' {
print ' Wait until Packer completes,' 'nvim-telescope/telescope-fzf-native.nvim',
print ' then restart nvim' -- NOTE: If you are having trouble with this installation,
print '==================================' -- refer to the README for telescope-fzf-native for more instructions.
return build = 'make',
end cond = function()
return vim.fn.executable 'make' == 1
end,
},
-- Automatically source and re-compile packer whenever you save this init.lua { -- Highlight, edit, and navigate code
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true }) 'nvim-treesitter/nvim-treesitter',
vim.api.nvim_create_autocmd('BufWritePost', { dependencies = {
command = 'source <afile> | silent! LspStop | silent! LspStart | PackerCompile', 'nvim-treesitter/nvim-treesitter-textobjects',
group = packer_group, },
pattern = vim.fn.expand '$MYVIMRC', build = ":TSUpdate",
}) },
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
-- require 'kickstart.plugins.autoformat',
-- require 'kickstart.plugins.debug',
-- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
-- up-to-date with whatever is in the kickstart repo.
--
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
--
-- An additional note is that if you only copied in the `init.lua`, you can just comment this line
-- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`.
{ import = 'custom.plugins' },
}, {})
-- [[ Setting options ]] -- [[ Setting options ]]
-- See `:help vim.o` -- See `:help vim.o`
@ -207,6 +199,11 @@ vim.wo.number = true
-- Enable mouse mode -- Enable mouse mode
vim.o.mouse = 'a' 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 -- Enable break indent
vim.o.breakindent = true vim.o.breakindent = true
@ -217,23 +214,21 @@ vim.o.undofile = true
vim.o.ignorecase = true vim.o.ignorecase = true
vim.o.smartcase = true vim.o.smartcase = true
-- Decrease update time -- Keep signcolumn on by default
vim.o.updatetime = 250
vim.wo.signcolumn = 'yes' vim.wo.signcolumn = 'yes'
-- Set colorscheme -- Decrease update time
vim.o.termguicolors = true vim.o.updatetime = 250
vim.cmd [[colorscheme onedark]] vim.o.timeout = true
vim.o.timeoutlen = 300
-- Set completeopt to have a better completion experience -- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect' vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Keymaps for better default experience -- Keymaps for better default experience
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
@ -254,39 +249,6 @@ vim.api.nvim_create_autocmd('TextYankPost', {
pattern = '*', pattern = '*',
}) })
-- Set lualine as statusline
-- See `:help lualine.txt`
require('lualine').setup {
options = {
icons_enabled = false,
theme = 'onedark',
component_separators = '|',
section_separators = '',
},
}
-- Enable Comment.nvim
require('Comment').setup()
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt`
require('indent_blankline').setup {
char = '',
show_trailing_blankline_indent = false,
}
-- Gitsigns
-- See `:help gitsigns.txt`
require('gitsigns').setup {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
}
-- [[ Configure Telescope ]] -- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()` -- See `:help telescope` and `:help telescope.setup()`
require('telescope').setup { require('telescope').setup {
@ -312,8 +274,9 @@ vim.keymap.set('n', '<leader>/', function()
winblend = 10, winblend = 10,
previewer = false, previewer = false,
}) })
end, { desc = '[/] Fuzzily search in current buffer]' }) end, { desc = '[/] Fuzzily search in current buffer' })
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>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>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>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
@ -324,7 +287,10 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
-- See `:help nvim-treesitter` -- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter -- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'help', 'vim' }, ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true, disable = { 'python' } }, indent = { enable = true, disable = { 'python' } },
@ -334,7 +300,7 @@ require('nvim-treesitter.configs').setup {
init_selection = '<c-space>', init_selection = '<c-space>',
node_incremental = '<c-space>', node_incremental = '<c-space>',
scope_incremental = '<c-s>', scope_incremental = '<c-s>',
node_decremental = '<c-backspace>', node_decremental = '<M-space>',
}, },
}, },
textobjects = { textobjects = {
@ -384,10 +350,10 @@ require('nvim-treesitter.configs').setup {
} }
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next) 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) vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
-- LSP settings. -- LSP settings.
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.
@ -446,7 +412,7 @@ local servers = {
-- rust_analyzer = {}, -- rust_analyzer = {},
-- tsserver = {}, -- tsserver = {},
sumneko_lua = { lua_ls = {
Lua = { Lua = {
workspace = { checkThirdParty = false }, workspace = { checkThirdParty = false },
telemetry = { enable = false }, telemetry = { enable = false },
@ -456,14 +422,11 @@ local servers = {
-- Setup neovim lua configuration -- Setup neovim lua configuration
require('neodev').setup() require('neodev').setup()
--
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Setup mason so it can manage external tooling
require('mason').setup()
-- Ensure the servers above are installed -- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig' local mason_lspconfig = require 'mason-lspconfig'
@ -481,13 +444,12 @@ mason_lspconfig.setup_handlers {
end, end,
} }
-- Turn on lsp status information
require('fidget').setup()
-- nvim-cmp setup -- nvim-cmp setup
local cmp = require 'cmp' local cmp = require 'cmp'
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
luasnip.config.setup {}
cmp.setup { cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)
@ -495,9 +457,11 @@ cmp.setup {
end, end,
}, },
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm { ['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
@ -527,35 +491,5 @@ cmp.setup {
}, },
} }
-- User Defined
-- Leap setup
require('leap').add_default_mappings()
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", {clear = true})
vim.api.nvim_create_autocmd({"BufEnter", "FocusGained" ,"InsertLeave"}, {
command = "set relativenumber",
group = my_group
}
)
vim.api.nvim_create_autocmd({"BufLeave", "FocusLost", "InsertEnter"}, {
command = "set norelativenumber",
group = my_group
}
)
-- Use ctrl-[hjkl] to select the active split!
vim.keymap.set('n', '<c-k', ':wincmd k<CR>', {silent = true})
vim.keymap.set('n', '<c-j>', ':wincmd j<CR>', {silent = true})
vim.keymap.set('n', '<c-h>', ':wincmd h<CR>', {silent = true})
vim.keymap.set('n', '<c-l>', ':wincmd l<CR>', {silent = true})
vim.o.cursorline = true
vim.o.cursorcolumn = true
vim.o.smartcase = false
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et

Loading…
Cancel
Save