Moved config over to lazy.nvim
This commit is contained in:
+173
-98
@@ -1,121 +1,197 @@
|
||||
require('packer').startup(function(use)
|
||||
-- Package manager
|
||||
use 'wbthomason/packer.nvim'
|
||||
-- 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 = ' '
|
||||
|
||||
-- LSP Configuration
|
||||
use {
|
||||
-- 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)
|
||||
|
||||
-- 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',
|
||||
|
||||
-- Detect tabstop and shiftwidth automatically
|
||||
--'tpope/vim-sleuth',
|
||||
|
||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
||||
-- The configuration is done below. Search for lspconfig to find it below.
|
||||
{ -- LSP Configuration & Plugins
|
||||
'neovim/nvim-lspconfig',
|
||||
requires = {
|
||||
dependencies = {
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
'williamboman/mason.nvim',
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
|
||||
-- Useful status updates for LSP
|
||||
'j-hui/fidget.nvim',
|
||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||
{ 'j-hui/fidget.nvim', opts = {} },
|
||||
|
||||
-- Additional lua configuration, makes nvim stuff amazing
|
||||
-- Additional lua configuration, makes nvim stuff amazing!
|
||||
'folke/neodev.nvim',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
-- Autocompletion
|
||||
use {
|
||||
{ -- Autocompletion
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'saadparwaiz1/cmp_luasnip'
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
use 'SirVer/ultisnips'
|
||||
use 'quangnguyen30192/cmp-nvim-ultisnips'
|
||||
-- Useful plugin to show you pending keybinds.
|
||||
{ 'folke/which-key.nvim', opts = {} },
|
||||
{ -- 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 = '~' },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Highlight, edit, and navigate code
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
pcall(require('nvim-treesitter.install').update { with_sync = true })
|
||||
{
|
||||
'morhetz/gruvbox',
|
||||
priority = 1000,
|
||||
config = function()
|
||||
vim.cmd.colorscheme 'gruvbox'
|
||||
end,
|
||||
}
|
||||
},
|
||||
|
||||
use { -- Additional text objects via treesitter
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
after = 'nvim-treesitter',
|
||||
}
|
||||
{ -- Set lualine as statusline
|
||||
'nvim-lualine/lualine.nvim',
|
||||
-- See `:help lualine.txt`
|
||||
opts = {
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
theme = 'gruvbox',
|
||||
component_separators = '|',
|
||||
section_separators = '',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- [Language Syntax]
|
||||
use 'karolbelina/uxntal.vim'
|
||||
{ -- Add indentation guides even on blank lines
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||
-- See `:help indent_blankline.txt`
|
||||
opts = {
|
||||
char = '┊',
|
||||
show_trailing_blankline_indent = false,
|
||||
},
|
||||
},
|
||||
|
||||
-- [Language Development]
|
||||
use {
|
||||
'fatih/vim-go',
|
||||
run = ':GoUpdateBinaries',
|
||||
}
|
||||
|
||||
use 'rust-lang/rust.vim'
|
||||
|
||||
use 'Julian/lean.nvim'
|
||||
|
||||
use 'OmniSharp/omnisharp-vim'
|
||||
|
||||
-- [Auto Formatting]
|
||||
|
||||
-- Google Java auto-format
|
||||
use 'google/vim-maktaba'
|
||||
use 'google/vim-codefmt'
|
||||
use 'google/vim-glaive'
|
||||
|
||||
-- Python auto-format
|
||||
use 'psf/black'
|
||||
|
||||
-- LaTeX
|
||||
use 'lervag/vimtex'
|
||||
use 'KeitaNakamura/tex-conceal.vim'
|
||||
|
||||
|
||||
-- Git related plugins
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rhubarb'
|
||||
use 'lewis6991/gitsigns.nvim'
|
||||
|
||||
-- Colorscheme
|
||||
use 'morhetz/gruvbox'
|
||||
|
||||
-- Fancier statusline
|
||||
use 'nvim-lualine/lualine.nvim'
|
||||
|
||||
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
|
||||
-- "gc" to comment visual regions/lines
|
||||
{ 'numToStr/Comment.nvim', opts = {} },
|
||||
|
||||
-- Fuzzy Finder (files, lsp, etc)
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
branch = '0.1.x',
|
||||
requires = { 'nvim-lua/plenary.nvim' },
|
||||
}
|
||||
{ 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } },
|
||||
|
||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available
|
||||
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable 'make' == 1 }
|
||||
-- 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,
|
||||
},
|
||||
|
||||
-- Add custom plugins to packer from ~/.config/nvim/lua/custom/plugins.lua
|
||||
local has_plugins, plugins = pcall(require, 'custom.plugins')
|
||||
if has_plugins then
|
||||
plugins(use)
|
||||
end
|
||||
end)
|
||||
{ -- Highlight, edit, and navigate code
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
dependencies = {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
},
|
||||
config = function()
|
||||
pcall(require('nvim-treesitter.install').update { with_sync = true })
|
||||
end,
|
||||
},
|
||||
|
||||
-- Automatically source and re-compile packer whenever you save this init.lua
|
||||
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
|
||||
vim.api.nvim_create_autocmd('BufWritePost', {
|
||||
command = 'source <afile> | silent! LspStop | silent! LspStart | PackerCompile',
|
||||
group = packer_group,
|
||||
pattern = vim.fn.expand '$MYVIMRC',
|
||||
})
|
||||
{
|
||||
'SirVer/ultisnips'
|
||||
},
|
||||
|
||||
{ 'quangnguyen30192/cmp-nvim-ultisnips' },
|
||||
|
||||
{ 'karolbelina/uxntal.vim' },
|
||||
|
||||
{
|
||||
'fatih/vim-go',
|
||||
build = ':GoUpdateBinaries',
|
||||
},
|
||||
|
||||
{ 'rust-lang/rust.vim' },
|
||||
{ 'Julian/lean.nvim' },
|
||||
{ 'Omnisharp/omnisharp-vim' },
|
||||
|
||||
-- Google Java auto-format
|
||||
{
|
||||
'google/vim-codefmt',
|
||||
dependencies = {
|
||||
'google/vim-maktaba',
|
||||
'google/vim-glaive',
|
||||
},
|
||||
},
|
||||
|
||||
{ 'psf/black' },
|
||||
|
||||
{ 'lervag/vimtex' },
|
||||
{ 'KeitaNakamura/tex-conceal.vim' },
|
||||
|
||||
{ 'tpope/vim-fugitive' },
|
||||
{ 'tpope/vim-rhubarb' },
|
||||
{ 'lewis6991/gitsigns.nvim' },
|
||||
|
||||
-- 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' },
|
||||
}, {})
|
||||
|
||||
-- LaTeX specific commands
|
||||
local texfiles = vim.api.nvim_create_augroup('texfiles', { clear = true})
|
||||
local texfiles = vim.api.nvim_create_augroup('texfiles', { clear = true })
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
command = 'setlocal spell colorcolumn=81 tw=80 conceallevel=1',
|
||||
group = texfiles,
|
||||
@@ -175,13 +251,13 @@ vim.g.rustfmt_fail_silently = 0
|
||||
vim.g.OmniSharp_server_path = '/usr/bin/omnisharp'
|
||||
|
||||
-- UltiSnips keybindings
|
||||
vim.g.UltiSnipsExpandTrigger="<tab>"
|
||||
vim.g.UltiSnipsJumpForwardTrigger="<c-b>"
|
||||
vim.g.UltiSnipsJumpBackwardTrigger="<c-z>"
|
||||
vim.g.UltiSnipsExpandTrigger = "<tab>"
|
||||
vim.g.UltiSnipsJumpForwardTrigger = "<c-b>"
|
||||
vim.g.UltiSnipsJumpBackwardTrigger = "<c-z>"
|
||||
|
||||
-- Vimtex configuration
|
||||
vim.g.vimtex_view_method = 'zathura'
|
||||
vim.g.vimtex_quickfix_mode=0
|
||||
vim.g.vimtex_quickfix_mode = 0
|
||||
vim.g.vimtex_compiler_latexmk = {
|
||||
options = {
|
||||
'-shell-escape',
|
||||
@@ -196,7 +272,6 @@ vim.g.python_highlight_all = 1
|
||||
|
||||
-- Set colorscheme
|
||||
vim.o.termguicolors = true
|
||||
vim.cmd [[colorscheme gruvbox]]
|
||||
|
||||
-- [[ Basic Keymaps ]]
|
||||
-- Set <space> as the leader key
|
||||
@@ -411,7 +486,7 @@ end
|
||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
||||
local servers = {
|
||||
--gopls = {},
|
||||
sumneko_lua = {
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
@@ -521,7 +596,7 @@ cmp.setup {
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs( -4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<Tab>'] = cmp.mapping.confirm {
|
||||
@@ -540,8 +615,8 @@ cmp.setup {
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
elseif luasnip.jumpable( -1) then
|
||||
luasnip.jump( -1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "6821b3ae27a57f1f3cf8ed030e4a55d70d0c4e43" },
|
||||
"LuaSnip": { "branch": "master", "commit": "f7c845749aba6096f041a73a26ba64f3817bab99" },
|
||||
"black": { "branch": "main", "commit": "25d886f52c2bbbb58386ac8050f4e67952507bc7" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
|
||||
"cmp-nvim-ultisnips": { "branch": "main", "commit": "43b69a235b2dc54db692049fe0d5cc60c6b58b4b" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||
"fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "f388995990aba04cfdc7c3ab870c33e280601109" },
|
||||
"gruvbox": { "branch": "master", "commit": "bf2885a95efdad7bd5e4794dd0213917770d79b7" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "5694483e8782f4d9a01ea8822166998924df5f00" },
|
||||
"lean.nvim": { "branch": "main", "commit": "f69875f98317c11fd48c4c4a8166a408244b7fe8" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "3f9c0ea157e88b08e2d11ec65002eeb6e421f0da" },
|
||||
"mason.nvim": { "branch": "main", "commit": "5f38eca64b7ed9f8a1f997ce67f2ccc80ab80c91" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "f081eb96d6a8dcc1835cdad1e5a46a254093cfc4" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "01f697a68905f9dcae70960a9eb013695a17f9a2" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "62856b20751b748841b0f3ec5a10b1e2f6a6dbc9" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "a9f0b1c2ba1d70de9189e1ade0e65346ad08849b" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "4b30081d2736e09f90c890a8a7adfe4df36f5b36" },
|
||||
"omnisharp-vim": { "branch": "master", "commit": "3799c45b576213e1959184783f54045f097df63f" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
|
||||
"rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" },
|
||||
"tex-conceal.vim": { "branch": "master", "commit": "93ae39d9222b0892684d02324b85ee9d3647bf8e" },
|
||||
"ultisnips": { "branch": "master", "commit": "0ad238b1910d447476b2d98f593322c1cdb71285" },
|
||||
"uxntal.vim": { "branch": "main", "commit": "b2d8bb9e225a7b0eeacccc406b319d2404eab4eb" },
|
||||
"vim-codefmt": { "branch": "master", "commit": "1b76987b6719bee259ba8d1e03a1e7f624a3615f" },
|
||||
"vim-fugitive": { "branch": "master", "commit": "62f42f013d866139fa23068ac2651b3f7e05a56f" },
|
||||
"vim-glaive": { "branch": "master", "commit": "3c5db8d279f86355914200119e8727a085863fcd" },
|
||||
"vim-go": { "branch": "master", "commit": "b8a41085bfd67fee97ad075c6df65590ce7417a7" },
|
||||
"vim-maktaba": { "branch": "master", "commit": "5d416e84d024538f5e5cf25c394d081802f0a35e" },
|
||||
"vim-rhubarb": { "branch": "master", "commit": "cad60fe382f3f501bbb28e113dfe8c0de6e77c75" },
|
||||
"vimtex": { "branch": "master", "commit": "112e62c1c873fb1910c08ed331f354ae017aac57" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "5224c261825263f46f6771f1b644cae33cd06995" }
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
-- autoformat.lua
|
||||
--
|
||||
-- Use your language server to automatically format your code on save.
|
||||
-- Adds additional commands as well to manage the behavior
|
||||
|
||||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
config = function()
|
||||
-- Switch for controlling whether you want autoformatting.
|
||||
-- Use :KickstartFormatToggle to toggle autoformatting on or off
|
||||
local format_is_enabled = true
|
||||
vim.api.nvim_create_user_command('KickstartFormatToggle', function()
|
||||
format_is_enabled = not format_is_enabled
|
||||
print('Setting autoformatting to: ' .. tostring(format_is_enabled))
|
||||
end, {})
|
||||
|
||||
-- Create an augroup that is used for managing our formatting autocmds.
|
||||
-- We need one augroup per client to make sure that multiple clients
|
||||
-- can attach to the same buffer without interfering with each other.
|
||||
local _augroups = {}
|
||||
local get_augroup = function(client)
|
||||
if not _augroups[client.id] then
|
||||
local group_name = 'kickstart-lsp-format-' .. client.name
|
||||
local id = vim.api.nvim_create_augroup(group_name, { clear = true })
|
||||
_augroups[client.id] = id
|
||||
end
|
||||
|
||||
return _augroups[client.id]
|
||||
end
|
||||
|
||||
-- Whenever an LSP attaches to a buffer, we will run this function.
|
||||
--
|
||||
-- See `:help LspAttach` for more information about this autocmd event.
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
|
||||
-- This is where we attach the autoformatting for reasonable clients
|
||||
callback = function(args)
|
||||
local client_id = args.data.client_id
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
local bufnr = args.buf
|
||||
|
||||
-- Only attach to clients that support document formatting
|
||||
if not client.server_capabilities.documentFormattingProvider then
|
||||
return
|
||||
end
|
||||
|
||||
-- Tsserver usually works poorly. Sorry you work with bad languages
|
||||
-- You can remove this line if you know what you're doing :)
|
||||
if client.name == 'tsserver' then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create an autocmd that will run *before* we save the buffer.
|
||||
-- Run the formatting command for the LSP that has just attached.
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
group = get_augroup(client),
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
if not format_is_enabled then
|
||||
return
|
||||
end
|
||||
|
||||
vim.lsp.buf.format {
|
||||
async = false,
|
||||
filter = function(c)
|
||||
return c.id == client.id
|
||||
end,
|
||||
}
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user