Migrate plugins from Plug to packer

This commit is contained in:
Fabian Becker 2021-05-23 20:54:12 +02:00
parent 0b81a1e8b2
commit 515a0416d4
12 changed files with 446 additions and 120 deletions

View File

@ -1,20 +1,26 @@
require('globals')
require('keymappings')
require('settings')
-- Convert to lua
vim.cmd('source ~/.config/nvim/vim-plug/plugins.vim')
require('plugins')
require('colorscheme')
require('lsp')
require('lsp.docker-ls')
require('lsp.python-ls')
require('lsp.julia-ls')
-- require('lsp.julia-ls')
require('lsp.json-ls')
require('lsp.elixir-ls')
require('lsp.go-ls')
require('lsp.terraform-ls')
require('plugins.telescope')
require('plugins.telescope-project')
require('plugins.compe')
require('plugins.which-key')
require('plugins.lualine')
--require('plugins.barbar')
require('plugins.tagbar')
require('plugins.sneak')
require('themes.nord')

View File

@ -12,7 +12,7 @@ O = {
number = true,
relative_number = true,
shell = 'zsh',
timeoutlen = 100,
timeoutlen = 500,
number = true,
scrolloff = 8,
noshowmode = true,

View File

@ -0,0 +1,132 @@
local execute = vim.api.nvim_command
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
execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
execute "packadd packer.nvim"
end
--- Check if a file or directory exists in this path
local function require_plugin(plugin)
local plugin_prefix = fn.stdpath("data") .. "/site/pack/packer/opt/"
local plugin_path = plugin_prefix .. plugin .. "/"
-- print('test '..plugin_path)
local ok, err, code = os.rename(plugin_path, plugin_path)
if not ok then
if code == 13 then
-- Permission denied, but it exists
return true
end
end
-- print(ok, err, code)
if ok then
vim.cmd("packadd " .. plugin)
end
return ok, err, code
end
vim.cmd "autocmd BufWritePost plugins.lua PackerCompile" -- Auto compile when there are changes in plugins.lua
return require("packer").startup(
function(use)
-- Packer can manage itself as an optional plugin
use "wbthomason/packer.nvim"
use {'airblade/vim-gitgutter'}
-- use {'andymass/vim-matchup'}
-- Load .editorconfig files
use {'editorconfig/editorconfig-vim'}
use {'junegunn/vim-easy-align'}
-- Multiple cursors for editing
use {'mg979/vim-visual-multi', branch='master'}
-- Goodies
use {'tpope/vim-abolish'}
use {'tpope/vim-fugitive'}
use {'tpope/vim-surround'}
-- Treesitter
use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}
use {'majutsushi/tagbar'}
vim.g.tagbar_ctags_bin = '/usr/local/bin/ctags'
-- Status Line and Bufferline
-- use {"glepnir/galaxyline.nvim"}
--use {"romgrk/barbar.nvim"}
use {
'hoob3rt/lualine.nvim',
requires = {'kyazdani42/nvim-web-devicons'}
}
use {'justinmk/vim-sneak'}
use {'machakann/vim-highlightedyank'}
-- let g:highlightedyank_highlight_duration = 100
-- Easy commenting for Vim
use {'preservim/nerdcommenter'}
-- NERD Tree - tree explorer
-- https://github.com/scrooloose/nerdtree
-- http://usevim.com/2012/07/18/nerdtree/
-- (loaded on first invocation of the command)
use {
'scrooloose/nerdtree',
requires = {'ryanoasis/vim-devicons'}
}
-- nerdtree-git-plugin - show git status in NERD Tree
-- https://github.com/Xuyuanp/nerdtree-git-plugi
use {'Xuyuanp/nerdtree-git-plugin'}
-- LSP / Language Server Protocol
use {'neovim/nvim-lspconfig'}
use {'hrsh7th/nvim-compe'}
use {'glepnir/lspsaga.nvim'}
use {'kabouzeid/nvim-lspinstall'}
use {'nvim-lua/lsp-status.nvim'}
use {'simrat39/symbols-outline.nvim'}
-- Terminal in floating window
use {'voldikss/vim-floaterm'}
-- Telescope fuzzy find files/grep
use {'nvim-lua/popup.nvim'}
use {'nvim-lua/plenary.nvim'}
use {'nvim-telescope/telescope.nvim'}
use {'nvim-telescope/telescope-project.nvim'}
-- Which Key
use {'folke/which-key.nvim'}
-- => Language Support
use {'neoclide/jsonc.vim'}
-- use {'vim-python/python-syntax', ft={'python'}, opt=true}
-- let g:python_highlight_all = 1
use {'JuliaEditorSupport/julia-vim', opt=true}
vim.g.latex_to_unicode_auto = 1
-- Formatting Julia Files
use {'kdheepak/JuliaFormatter.vim'}
-- themes & colorschemes
use {'challenger-deep-theme/vim', as='challenger-deep' }
use {'dracula/vim', as='dracula' }
use {'shaunsingh/moonlight.nvim', as='moonlight'}
use {'arcticicestudio/nord-vim'}
require_plugin('julia-vim')
end
)

View File

@ -0,0 +1,231 @@
local vim = vim
local gl = require('galaxyline')
local utils = require('utils')
local gls = gl.section
gl.short_line_list = { 'defx', 'packager', 'vista' }
-- Colors
local colors = {
bg = '#282a36',
fg = '#f8f8f2',
section_bg = '#38393f',
yellow = '#f1fa8c',
cyan = '#8be9fd',
green = '#50fa7b',
orange = '#ffb86c',
magenta = '#ff79c6',
blue = '#8be9fd',
red = '#ff5555'
}
-- Local helper functions
local buffer_not_empty = function()
return not utils.is_buffer_empty()
end
local in_git_repo = function ()
local vcs = require('galaxyline.provider_vcs')
local branch_name = vcs.get_git_branch()
return branch_name ~= nil
end
local checkwidth = function()
return utils.has_width_gt(40) and in_git_repo()
end
local mode_color = function()
local mode_colors = {
n = colors.cyan,
i = colors.green,
c = colors.orange,
V = colors.magenta,
[''] = colors.magenta,
v = colors.magenta,
R = colors.red,
}
local color = mode_colors[vim.fn.mode()]
if color == nil then
color = colors.red
end
return color
end
-- Left side
gls.left[1] = {
FirstElement = {
provider = function() return '' end,
highlight = { colors.cyan, colors.section_bg }
},
}
gls.left[2] = {
ViMode = {
provider = function()
local alias = {
n = 'NORMAL',
i = 'INSERT',
c = 'COMMAND',
V = 'VISUAL',
[''] = 'VISUAL',
v = 'VISUAL',
R = 'REPLACE',
}
vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color())
local alias_mode = alias[vim.fn.mode()]
if alias_mode == nil then
alias_mode = vim.fn.mode()
end
return alias_mode..' '
end,
highlight = { colors.bg, colors.bg },
separator = "",
separator_highlight = {colors.bg, colors.section_bg},
},
}
gls.left[3] ={
FileIcon = {
provider = 'FileIcon',
condition = buffer_not_empty,
highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.section_bg },
},
}
gls.left[4] = {
FileName = {
provider = 'FileName',
condition = buffer_not_empty,
highlight = { colors.fg, colors.section_bg },
separator = "",
separator_highlight = {colors.section_bg, colors.bg},
}
}
gls.left[5] = {
GitIcon = {
provider = function() return '' end,
condition = in_git_repo,
highlight = {colors.red,colors.bg},
}
}
gls.left[6] = {
GitBranch = {
provider = function()
local vcs = require('galaxyline.provider_vcs')
local branch_name = vcs.get_git_branch()
if (string.len(branch_name) > 28) then
return string.sub(branch_name, 1, 25).."..."
end
return branch_name .. " "
end,
condition = in_git_repo,
highlight = {colors.fg,colors.bg},
}
}
gls.left[7] = {
DiffAdd = {
provider = 'DiffAdd',
condition = checkwidth,
icon = '',
highlight = { colors.green, colors.bg },
}
}
gls.left[8] = {
DiffModified = {
provider = 'DiffModified',
condition = checkwidth,
icon = '',
highlight = { colors.orange, colors.bg },
}
}
gls.left[9] = {
DiffRemove = {
provider = 'DiffRemove',
condition = checkwidth,
icon = '',
highlight = { colors.red,colors.bg },
}
}
gls.left[10] = {
LeftEnd = {
provider = function() return '' end,
condition = buffer_not_empty,
highlight = {colors.section_bg,colors.bg}
}
}
gls.left[11] = {
DiagnosticError = {
provider = 'DiagnosticError',
icon = '',
highlight = {colors.red,colors.section_bg}
}
}
gls.left[12] = {
Space = {
provider = function () return ' ' end,
highlight = {colors.section_bg,colors.section_bg},
}
}
gls.left[13] = {
DiagnosticWarn = {
provider = 'DiagnosticWarn',
icon = '',
highlight = {colors.orange,colors.section_bg},
}
}
gls.left[14] = {
Space = {
provider = function () return ' ' end,
highlight = {colors.section_bg,colors.section_bg},
}
}
gls.left[15] = {
DiagnosticInfo = {
provider = 'DiagnosticInfo',
icon = '',
highlight = {colors.blue,colors.section_bg},
separator = '',
separator_highlight = { colors.section_bg, colors.bg },
}
}
-- Right side
gls.right[1]= {
FileFormat = {
provider = function() return vim.bo.filetype end,
highlight = { colors.fg,colors.section_bg },
separator = '',
separator_highlight = { colors.section_bg,colors.bg },
}
}
gls.right[2] = {
LineInfo = {
provider = 'LineColumn',
highlight = { colors.fg, colors.section_bg },
separator = ' | ',
separator_highlight = { colors.bg, colors.section_bg },
},
}
-- Short status line
gls.short_line_left[1] = {
BufferType = {
provider = 'FileTypeName',
highlight = { colors.fg, colors.section_bg },
separator = '',
separator_highlight = { colors.section_bg, colors.bg },
}
}
gls.short_line_right[1] = {
BufferIcon = {
provider= 'BufferIcon',
highlight = { colors.yellow, colors.section_bg },
separator = '',
separator_highlight = { colors.section_bg, colors.bg },
}
}
-- Force manual load so that nvim boots with a status line
gl.load_galaxyline()

View File

@ -0,0 +1,27 @@
require'lualine'.setup {
options = {
icons_enabled = true,
theme = 'nord',
component_separators = {'', ''},
section_separators = {'', ''},
disabled_filetypes = {}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch'},
lualine_c = {'filename', require'lsp-status'.status},
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 = {}
}

View File

@ -0,0 +1,3 @@
vim.cmd([[
let g:sneak#label = 1
]])

View File

@ -0,0 +1 @@
vim.g.tagbar_ctags_bin = '/usr/local/bin/ctags'

View File

@ -7,8 +7,8 @@ require('telescope').setup {
find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'},
prompt_position = "bottom",
-- prompt_prefix = " ",
prompt_prefix = "",
selection_caret = "",
prompt_prefix = " ",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
@ -43,7 +43,7 @@ require('telescope').setup {
-- To disable a keymap, put [map] = false
-- So, to not map "<C-n>", just put
-- ["<c-x>"] = false,
["<esc>"] = actions.close,
-- Otherwise, just set the mapping to the function that you want it to be.
-- ["<C-i>"] = actions.select_horizontal,
@ -58,6 +58,7 @@ require('telescope').setup {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
["<esc>"] = actions.close,
-- ["<C-i>"] = my_cool_custom_action,
}
}

View File

@ -50,18 +50,25 @@ vim.g.mapleader = ' '
-- explorer
vim.api.nvim_set_keymap('n', '<Leader>e', ':NERDTreeToggle<CR>', {noremap = true, silent = true})
-- dashboard
vim.api.nvim_set_keymap('n', '<Leader>;', ':Dashboard<CR>', {noremap = true, silent = true})
-- TODO create entire treesitter section
local mappings = {
["/"] = "Comment",
["e"] = "Explorer",
f = {
f = {":Telescope find_files<CR>", "Find File"}
["c"] = "NERDCommenter",
b = {
name = "+Buffers",
b = {"<C-^>", "Toggle Buffer"},
d = {"<cmd>bd<cr>", "Close Buffer"},
k = {"<cmd>bd!<cr>", "Kill Buffer"},
},
f = {
name = "Find",
f = {"<cmd>Telescope find_files<cr>", "Find File"},
p = {"<cmd>lua require'telescope'.extensions.project.project{}<CR>", "Project"},
g = {"<cmd>lua require'telescope.builtin'.live_grep()<cr>", "Grep files"},
b = {"<cmd>lua require'telescope.builtin'.buffers{}<cr>", "Buffers"},
t = {"<cmd>lua require'telescope.builtin'.help_tags{}<cr>", "Tags"},
},
["f"] = "Find File",
g = {
name = "+Git",
j = {"<cmd>NextHunk<cr>", "Next Hunk"},
@ -94,7 +101,9 @@ local mappings = {
s = {"<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols"},
S = {"<cmd>Telescope lsp_workspace_symbols<cr>", "Workspace Symbols"}
},
d = {
f = {":lua require'functions'.edit_dotfiles()<cr>", "Dotfiles search"}
},
s = {
name = "+Search",
b = {"<cmd>Telescope git_branches<cr>", "Checkout branch"},
@ -112,6 +121,10 @@ local mappings = {
name = "+Session",
s = {"<cmd>SessionSave<cr>", "Save Session"},
l = {"<cmd>SessionLoad<cr>", "Load Session"}
},
t = {
name = "+Tagbar",
t = {"<cmd>TagbarToggle<cr>", "Toggle Tagbar"},
}
}

View File

@ -0,0 +1,4 @@
vim.g.nord_cursor_line_number_background = 1
vim.g.nord_bold = 1
vim.g.nord_italic = 1
vim.g.nord_italic_comments = 1

View File

@ -0,0 +1,13 @@
local M = {}
function M.is_buffer_empty()
-- Check whether the current buffer is empty
return vim.fn.empty(vim.fn.expand('%:t')) == 1
end
function M.has_width_gt(cols)
-- Check if the windows width is greater than a given number of columns
return vim.fn.winwidth(0) / 2 > cols
end
return M

View File

@ -1,105 +0,0 @@
call plug#begin('~/.local/share/nvim/plugged')
Plug 'airblade/vim-gitgutter'
" Plug 'andymass/vim-matchup'
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/vim-easy-align'
" Multiple cursors for editing
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'edkolev/tmuxline.vim'
Plug 'majutsushi/tagbar'
let g:tagbar_ctags_bin = '/usr/local/bin/ctags'
Plug 'itchyny/lightline.vim'
let g:lightline = {
\ 'colorscheme': 'challenger_deep',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'gitbranch', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'FugitiveHead',
\ },
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ }
Plug 'airblade/vim-rooter'
let g:rooter_manual_only = 1
Plug 'justinmk/vim-sneak'
let g:sneak#label = 1
Plug 'machakann/vim-highlightedyank'
let g:highlightedyank_highlight_duration = 100
" Easy commenting for Vim
Plug 'preservim/nerdcommenter'
" NERD Tree - tree explorer
" https://github.com/scrooloose/nerdtree
" http://usevim.com/2012/07/18/nerdtree/
" (loaded on first invocation of the command)
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'ryanoasis/vim-devicons'
" nerdtree-git-plugin - show git status in NERD Tree
" https://github.com/Xuyuanp/nerdtree-git-plugi
" Plug 'Xuyuanp/nerdtree-git-plugin'
" Enforce editor settings
" https://github.com/editorconfig/editorconfig-vim
Plug 'editorconfig/editorconfig-vim'
" LSP / Language Server Protocol
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-compe'
Plug 'glepnir/lspsaga.nvim'
Plug 'kabouzeid/nvim-lspinstall'
" Terminal in floating window
Plug 'voldikss/vim-floaterm'
" Telescope fuzzy find files/grep
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-project.nvim'
" Which Key
Plug 'folke/which-key.nvim'
"""""""""""""""""""""""""
" => Language Support
"""""""""""""""""""""""""
Plug 'neoclide/jsonc.vim'
Plug 'vim-python/python-syntax'
let g:python_highlight_all = 1
Plug 'JuliaEditorSupport/julia-vim'
let g:latex_to_unicode_auto = 1
" Formatting Julia Files
Plug 'kdheepak/JuliaFormatter.vim'
" themes & colorschemes
Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' }
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'arcticicestudio/nord-vim'
let g:nord_cursor_line_number_background = 1
let g:nord_bold = 1
let g:nord_italic = 1
let g:nord_italic_comments = 1
Plug 'shaunsingh/moonlight.nvim'
call plug#end()