Refactor nvim packer configuration
This commit is contained in:
parent
3138316af8
commit
1b277bf887
11 changed files with 31 additions and 24 deletions
1
home/.config/nvim/lua/plugins/bufferline.lua
Normal file
1
home/.config/nvim/lua/plugins/bufferline.lua
Normal file
|
@ -0,0 +1 @@
|
|||
require('bufferline').setup{}
|
49
home/.config/nvim/lua/plugins/colorscheme.lua
Normal file
49
home/.config/nvim/lua/plugins/colorscheme.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
require('catppuccin').setup({
|
||||
transparent_background = false,
|
||||
term_colors = false,
|
||||
compile = {enabled = true, path = vim.fn.stdpath 'cache' .. '/catppuccin'},
|
||||
styles = {
|
||||
comments = {'italic'},
|
||||
functions = {'italic'},
|
||||
keywords = {'italic'},
|
||||
strings = {},
|
||||
variables = {}
|
||||
},
|
||||
integrations = {
|
||||
treesitter = true,
|
||||
native_lsp = {
|
||||
enabled = true,
|
||||
virtual_text = {
|
||||
errors = {'italic'},
|
||||
hints = {'italic'},
|
||||
warnings = {'italic'},
|
||||
information = {'italic'}
|
||||
},
|
||||
underlines = {
|
||||
errors = {'underline'},
|
||||
hints = {'underline'},
|
||||
warnings = {'underline'},
|
||||
information = {'underline'}
|
||||
}
|
||||
},
|
||||
lsp_trouble = false,
|
||||
lsp_saga = false,
|
||||
gitgutter = true,
|
||||
gitsigns = false,
|
||||
telescope = true,
|
||||
nvimtree = {enabled = false, show_root = false},
|
||||
which_key = false,
|
||||
indent_blankline = {enabled = true, colored_indent_levels = false},
|
||||
dashboard = false,
|
||||
neogit = false,
|
||||
vim_sneak = false,
|
||||
fern = false,
|
||||
barbar = false,
|
||||
bufferline = false,
|
||||
markdown = false,
|
||||
lightspeed = false,
|
||||
ts_rainbow = false,
|
||||
hop = false
|
||||
}
|
||||
})
|
||||
vim.cmd [[colorscheme catppuccin]]
|
57
home/.config/nvim/lua/plugins/completion.lua
Normal file
57
home/.config/nvim/lua/plugins/completion.lua
Normal file
|
@ -0,0 +1,57 @@
|
|||
-- Add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
--
|
||||
-- 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' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
}
|
||||
|
||||
-- load friendly-snippets to luasnip
|
||||
require('luasnip/loaders/from_vscode').lazy_load()
|
7
home/.config/nvim/lua/plugins/indent-blankline.lua
Normal file
7
home/.config/nvim/lua/plugins/indent-blankline.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
vim.opt.list = true
|
||||
|
||||
require('indent_blankline').setup {
|
||||
space_char_blankline = ' ',
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
}
|
143
home/.config/nvim/lua/plugins/init.lua
Normal file
143
home/.config/nvim/lua/plugins/init.lua
Normal file
|
@ -0,0 +1,143 @@
|
|||
local fn = vim.fn
|
||||
|
||||
-- Install packer if it's not yet installed
|
||||
local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
print('installing packer')
|
||||
Packer_bootstrap = fn.system({
|
||||
'git', 'clone', '--depth', '1',
|
||||
'https://github.com/wbthomason/packer.nvim', install_path
|
||||
})
|
||||
vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' ..
|
||||
vim.o.runtimepath
|
||||
print('installed packer')
|
||||
end
|
||||
|
||||
-- Configure packer
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
require('packer').startup(function()
|
||||
local use = require('packer').use
|
||||
|
||||
-- The plugin manager itself
|
||||
use {'wbthomason/packer.nvim', opt=true}
|
||||
|
||||
-- Colorscheme
|
||||
use({'catppuccin/nvim', as = 'catppuccin'})
|
||||
|
||||
-- Git in signcolumn
|
||||
use 'airblade/vim-gitgutter'
|
||||
|
||||
-- Statusline
|
||||
use {
|
||||
'hoob3rt/lualine.nvim',
|
||||
requires = {'kyazdani42/nvim-web-devicons', opt = true}
|
||||
}
|
||||
|
||||
-- Tabline/bufferline
|
||||
use {
|
||||
'akinsho/nvim-bufferline.lua',
|
||||
tag = '*',
|
||||
requires = 'kyazdani42/nvim-web-devicons'
|
||||
}
|
||||
|
||||
-- Git commands
|
||||
use 'tpope/vim-fugitive'
|
||||
|
||||
-- Indent characters
|
||||
use 'lukas-reineke/indent-blankline.nvim'
|
||||
|
||||
-- Tree explorer
|
||||
use {'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons'}
|
||||
|
||||
-- Telescope
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {{'nvim-lua/plenary.nvim'}}
|
||||
}
|
||||
use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} -- Use fzf for fuzzy finder
|
||||
use {'nvim-telescope/telescope-ui-select.nvim'} -- Replace vim built in select with telescope
|
||||
|
||||
-- Do stuff as sudo
|
||||
use 'lambdalisue/suda.vim'
|
||||
|
||||
-- Read editorconfig settings
|
||||
use 'editorconfig/editorconfig-vim'
|
||||
|
||||
-- Configs for built-in LSP
|
||||
use 'neovim/nvim-lspconfig'
|
||||
|
||||
-- Install LSP server executables
|
||||
use {"williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim"}
|
||||
|
||||
-- Additional LSP features for Java
|
||||
use 'mfussenegger/nvim-jdtls'
|
||||
|
||||
-- Display function signature
|
||||
use {'ray-x/lsp_signature.nvim'}
|
||||
|
||||
-- Completion
|
||||
use 'hrsh7th/nvim-cmp' -- Autocompletion plugin
|
||||
use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp
|
||||
use 'hrsh7th/cmp-path' -- Path source for nvim-cmp
|
||||
use 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp
|
||||
use 'L3MON4D3/LuaSnip' -- Snippets plugin
|
||||
use 'rafamadriz/friendly-snippets' -- Snippets collection
|
||||
|
||||
-- treesitter syntax highlight
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
require('nvim-treesitter.install').update({with_sync = true})
|
||||
end
|
||||
}
|
||||
|
||||
-- treesitter plugin for commentstring
|
||||
use 'JoosepAlviste/nvim-ts-context-commentstring'
|
||||
|
||||
-- Additional plugins for formats not supported
|
||||
-- by treesitter
|
||||
use 'jamespeapen/swayconfig.vim'
|
||||
|
||||
-- mappings for commenting in code
|
||||
use 'tpope/vim-commentary'
|
||||
|
||||
-- we all know this one
|
||||
use 'tpope/vim-surround'
|
||||
|
||||
-- Formatter plugin
|
||||
use 'sbdchd/neoformat'
|
||||
|
||||
-- Make editing passwords safer
|
||||
use {
|
||||
'https://git.zx2c4.com/password-store',
|
||||
rtp = 'contrib/vim/redact_pass.vim'
|
||||
}
|
||||
|
||||
-- Neovim inside Firefox
|
||||
use {
|
||||
'glacambre/firenvim',
|
||||
run = function() vim.fn['firenvim#install'](0) end
|
||||
}
|
||||
|
||||
-- Vim <3 Asciidoctor
|
||||
use 'habamax/vim-asciidoctor'
|
||||
|
||||
-- Sync plugins if Packer was just
|
||||
-- installed
|
||||
if Packer_bootstrap then
|
||||
print('syncing')
|
||||
require('packer').sync()
|
||||
print('synced')
|
||||
end
|
||||
end)
|
||||
|
||||
-- Source configurations
|
||||
require 'plugins/lualine'
|
||||
require 'plugins/bufferline'
|
||||
require 'plugins/lsp'
|
||||
require 'plugins/completion'
|
||||
require 'plugins/treesitter'
|
||||
require 'plugins/indent-blankline'
|
||||
require 'plugins/nvim-tree'
|
||||
require 'plugins/colorscheme'
|
||||
require 'plugins/telescope'
|
87
home/.config/nvim/lua/plugins/lsp.lua
Normal file
87
home/.config/nvim/lua/plugins/lsp.lua
Normal file
|
@ -0,0 +1,87 @@
|
|||
local M = {}
|
||||
local lspconfig = require('lspconfig');
|
||||
--
|
||||
|
||||
M.lsp_map_keys = function(server, bufnr)
|
||||
local function map_key(...)
|
||||
-- Map to buffer if buffer number is supplied,
|
||||
-- globally otherwise
|
||||
if bufnr == nil then
|
||||
vim.api.nvim_set_keymap(...)
|
||||
else
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local keymapOpts = {noremap = true, silent = true}
|
||||
map_key('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', keymapOpts)
|
||||
map_key('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', keymapOpts)
|
||||
map_key('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', keymapOpts)
|
||||
map_key('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', keymapOpts)
|
||||
map_key('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', '<space>wr',
|
||||
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', keymapOpts)
|
||||
map_key('n', '<space>wl',
|
||||
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', keymapOpts)
|
||||
map_key('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', keymapOpts)
|
||||
map_key('n', '<space>e',
|
||||
'<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', keymapOpts)
|
||||
map_key('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', keymapOpts)
|
||||
map_key('n', '<space>q', '<cmd>lua vim.diagnostic.set_loclist()<CR>',
|
||||
keymapOpts)
|
||||
map_key('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', keymapOpts)
|
||||
end
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
-- Setup LSP signature plugin
|
||||
require('lsp_signature').setup()
|
||||
|
||||
-- Setup mason
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({automatic_installation = true})
|
||||
|
||||
-- LSP servers setup
|
||||
lspconfig.tsserver.setup {{}, on_attach = M.lsp_map_keys}
|
||||
lspconfig.yamlls.setup {{}, on_attach = M.lsp_map_keys}
|
||||
lspconfig.jsonls.setup {{}, on_attach = M.lsp_map_keys}
|
||||
|
||||
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 = vim.split(package.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}
|
||||
}
|
||||
},
|
||||
on_attach = M.lsp_map_keys,
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
return M
|
3
home/.config/nvim/lua/plugins/lualine.lua
Normal file
3
home/.config/nvim/lua/plugins/lualine.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
require'lualine'.setup {
|
||||
options = {theme = 'catppuccin'},
|
||||
}
|
1
home/.config/nvim/lua/plugins/nvim-tree.lua
Normal file
1
home/.config/nvim/lua/plugins/nvim-tree.lua
Normal file
|
@ -0,0 +1 @@
|
|||
require'nvim-tree'.setup {}
|
4
home/.config/nvim/lua/plugins/telescope.lua
Normal file
4
home/.config/nvim/lua/plugins/telescope.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
local telescope = require('telescope')
|
||||
telescope.setup {}
|
||||
telescope.load_extension('fzf')
|
||||
telescope.load_extension('ui-select')
|
14
home/.config/nvim/lua/plugins/treesitter.lua
Normal file
14
home/.config/nvim/lua/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = {
|
||||
'bash', 'c', 'css', 'dockerfile', 'html', 'http', 'java', 'json',
|
||||
'json5', 'latex', 'lua', 'make', 'markdown', 'php', 'python', 'regex',
|
||||
'rst', 'scss', 'toml', 'tsx', 'typescript', 'javascript', 'yaml'
|
||||
},
|
||||
highlight = {enable = true},
|
||||
indent = {enable = true},
|
||||
incremental_selection = {enable = true},
|
||||
context_commentstring = {enable = true}
|
||||
}
|
||||
|
||||
--vim.wo.foldmethod = 'expr'
|
||||
--im.wo.foldexpr = 'nvim_treesitter#foldexpr()'
|
Loading…
Add table
Add a link
Reference in a new issue