1
0
Fork 0

Initial neovim config.

This commit is contained in:
Vivianne 2021-10-12 22:54:51 -07:00
commit 723793945b
5 changed files with 540 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
plugin/packer_compiled.lua
local.vim

109
init.vim Normal file
View File

@ -0,0 +1,109 @@
let $CONFIG = stdpath('config')
let $SCR_PLUGINS = $CONFIG . '/lua/plugins.lua'
let $SCR_INIT = $CONFIG . '/init.vim'
if has('win32')
source $VIMRUNTIME\mswin.vim
endif
set termguicolors
lua require('plugins')
filetype plugin indent on
set tabstop=2 softtabstop=0 shiftwidth=2 expandtab smarttab autoindent
set incsearch ignorecase smartcase hlsearch
set wildmode=longest,list,full wildmenu
set ruler laststatus=2 showcmd showmode
" set list listchars=trail:
set fillchars+=vert:\
set wrap breakindent
set encoding=utf-8
set textwidth=0
set hidden
set number
set title
set mouse=a
set cursorline
set updatetime=300
set emoji
set noshowcmd
set noshowmode
syntax on
colorscheme dracula
nnoremap <silent>]b :BufferLineCycleNext<CR>
nnoremap <silent>[b :BufferLineCyclePrev<CR>
nnoremap <silent><leader>bp :BufferLinePick<CR>
nnoremap <silent><leader>bcc :BufferLinePickClose<CR>
nnoremap <silent><leader>bcl :BufferLineCloseLeft<CR>
nnoremap <silent><leader>bcr :BufferLineCloseRight<CR>
augroup packer_user_config
autocmd!
autocmd BufWritePost $SCR_PLUGINS source <afile> | PackerCompile
augroup end
augroup init_refresh
autocmd!
autocmd BufWritePost $SCR_INIT source <afile>
augroup end
augroup telescope
autocmd!
autocmd QuickFixCmdPost qf :Telescope quickfix<CR>
augroup end
if exists('g:fvim_loaded')
nnoremap <silent> <C-ScrollWheelUp> :set guifont=+<CR>
nnoremap <silent> <C-ScrollWheelDown> :set guifont=-<CR>
FVimCursorSmoothMove v:true
FVimCursorSmoothBlink v:true
FVimBackgroundComposition 'transparent'
FVimBackgroundOpacity 0.90
FVimBackgroundAltOpacity 0.85
FVimCustomTitleBar v:true
FVimFontLigature v:true
set guifont=JetBrains\ Mono:h13
endif
nnoremap <leader><leader> :NvimTreeToggle<CR>
let g:scrollview_current_only = 1
nnoremap <leader>vv <cmd>e $SCR_INIT<CR>
nnoremap <leader>vp <cmd>e $SCR_PLUGINS<CR>
" Telescope binds
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fq <cmd>Telescope quickfix<cr>
nnoremap <leader>fc <cmd>Telescope command_history<cr>
nnoremap <leader>fs <cmd>Telescope search_history<cr>
command CDC cd %:p:h
" wiki.vim bindings
let g:wiki_filetypes = ['md']
nnoremap <leader>fw <cmd>lua require'telescope.builtin'.find_files({ cwd = vim.g.wiki_root })<CR>
nnoremap <leader>fW <cmd>lua require'telescope.builtin'.live_grep({ cwd = vim.g.wiki_root })<CR>
nnoremap <leader>ft <cmd>WikiTagSearch<CR>
let s:tag_parser = deepcopy(g:wiki#tags#default_parser)
let s:tag_parser.re_match = '\v%(^|\s)#\zs[^# ]+'
let s:tag_parser.re_findstart = '\v%(^|\s)#\zs[^# ]+'
let g:wiki_tag_parsers = [s:tag_parser]
let g:lt_location_list_toggle_map = '<leader>l'
let g:lt_quickfix_list_toggle_map = '<leader>q'
" machine-specific settings
source $CONFIG\local.vim

13
lua/conf/utils.lua Normal file
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

@ -0,0 +1,321 @@
local gl = require 'galaxyline'
local utils = require 'conf.utils'
local condition = require 'galaxyline.condition'
local vcs = require 'galaxyline.providers.vcs'
local fileinfo = require 'galaxyline.providers.fileinfo'
local gls = gl.section
gl.short_line_list = {
'packer',
'NvimTree',
'Outline',
'Trouble',
'dap-repl',
'dapui_scopes',
'dapui_breakpoints',
'dapui_stacks',
'dapui_watches',
}
local colors = {
bg = '#282c34',
fg = '#abb2bf',
section_bg = '#38393f',
blue = '#61afef',
green = '#98c379',
purple = '#c678dd',
orange = '#e5c07b',
red = '#e06c75',
yellow = '#e5c07b',
darkgrey = '#2c323d',
middlegrey = '#8791A5',
}
local mode_colors = {
['n'] = colors.green,
['i'] = colors.blue,
['c'] = colors.green,
['t'] = colors.blue,
['v'] = colors.purple,
['\x16'] = colors.purple,
['V'] = colors.purple,
['R'] = colors.red,
['s'] = colors.red,
['S'] = colors.red,
['ic'] = colors.blue,
}
local mode_names = {
['n'] = 'NORMAL',
['i'] = 'INSERT',
['c'] = 'COMMAND',
['t'] = 'TERMINAL',
['v'] = 'VISUAL',
['\x16'] = 'V-BLOCK',
['V'] = 'V-LINE',
['R'] = 'REPLACE',
['s'] = 'SELECT',
['S'] = 'S-LINE',
['ic'] = 'COMPLETION',
}
-- Local helper functions
local buffer_not_empty = function()
return not utils.is_buffer_empty()
end
local checkwidth = function()
return utils.has_width_gt(35) and buffer_not_empty()
end
local is_file = function()
return vim.bo.buftype ~= 'nofile'
end
local function has_value(tab, val)
for _, value in ipairs(tab) do
if value[1] == val then
return true
end
end
return false
end
local get_mode = function()
return vim.api.nvim_get_mode()['mode']
end
local mode_color = function(mode)
local color = mode_colors[mode]
if color ~= nil then
return color
end
print 'statusline: error looking up vi mode color'
return colors.middlegrey
end
local vi_mode = function()
local mode = get_mode()
local color = mode_color(mode)
vim.cmd('hi GalaxyViMode guibg=' .. color)
local alias = mode_names[mode]
if alias ~= nil then
if not utils.has_width_gt(35) then
alias = alias:sub(1, 1)
end
else
alias = mode
end
return ' ' .. alias .. ' '
end
local function file_readonly()
if vim.bo.filetype == 'help' then
return false
end
if vim.bo.readonly then
return true
end
return false
end
local function file_name()
local file = vim.fn.expand '%:t'
if not file then
return ''
end
if file_readonly() then
return file .. ''
end
if vim.bo.modifiable and vim.bo.modified then
return file .. ''
end
return file .. ' '
end
local function split(str, sep)
local res = {}
local n = 1
for w in str:gmatch('([^' .. sep .. ']*)') do
res[n] = res[n] or w -- only set once (so the blank after a string is ignored)
if w == '' then
n = n + 1
end -- step forwards on a blank but not a string
end
return res
end
local function file_path()
local fp = vim.fn.fnamemodify(vim.fn.expand '%', ':~:.:h')
local tbl = split(fp, '/')
local len = #tbl
if len > 2 and not len == 3 and not tbl[0] == '~' then
return '…/' .. table.concat(tbl, '/', len - 1) .. '/' -- shorten filepath to last 2 folders
-- alternative: only 1 containing folder using vim builtin function
-- return '…/' .. vim.fn.fnamemodify(vim.fn.expand '%', ':p:h:t') .. '/'
else
return fp .. '/'
end
end
local function get_basename(file)
return file:match '^.+/(.+)$'
end
local git_root = function()
local git_dir = vcs.get_git_dir()
if not git_dir then
return ''
end
local git_root = git_dir:gsub('/.git/?$', '')
return get_basename(git_root)
end
-- Left side
gls.left[1] = {
ViMode = {
provider = { vi_mode },
highlight = { colors.bg, colors.bg, 'bold' },
},
}
gls.left[2] = {
FileIcon = {
provider = {
function()
return ' '
end,
'FileIcon',
},
condition = buffer_not_empty,
highlight = {
fileinfo.get_file_icon,
colors.section_bg,
},
},
}
gls.left[3] = {
FilePath = {
provider = file_path,
condition = function()
return is_file() and checkwidth()
end,
highlight = { colors.middlegrey, colors.section_bg },
},
}
gls.left[4] = {
FileName = {
provider = file_name,
condition = buffer_not_empty,
highlight = { colors.fg, colors.section_bg },
separator = '',
separator_highlight = { colors.section_bg, colors.bg },
},
}
-- Right side
gls.right[1] = {
DiffAdd = {
provider = 'DiffAdd',
condition = checkwidth,
icon = '+',
highlight = { colors.green, colors.bg },
separator = ' ',
separator_highlight = { colors.section_bg, colors.bg },
},
}
gls.right[2] = {
DiffModified = {
provider = 'DiffModified',
condition = checkwidth,
icon = '~',
highlight = { colors.orange, colors.bg },
},
}
gls.right[3] = {
DiffRemove = {
provider = 'DiffRemove',
condition = checkwidth,
icon = '-',
highlight = { colors.red, colors.bg },
},
}
gls.right[4] = {
Space = {
provider = function()
return ' '
end,
highlight = { colors.section_bg, colors.bg },
},
}
gls.right[6] = {
GitBranch = {
provider = {
function()
return ''
end,
'GitBranch',
},
condition = condition.check_git_workspace,
highlight = { colors.middlegrey, colors.bg },
},
}
gls.right[7] = {
GitRoot = {
provider = git_root,
condition = function()
return utils.has_width_gt(50) and condition.check_git_workspace
end,
highlight = { colors.fg, colors.bg },
separator = ' ',
separator_highlight = { colors.middlegrey, colors.bg },
},
}
gls.right[8] = {
PerCent = {
provider = 'LinePercent',
separator = '',
separator_highlight = { colors.blue, colors.bg },
highlight = { colors.darkgrey, colors.blue },
},
}
-- Short status line
gls.short_line_left[1] = {
FileIcon = {
provider = {
function()
return ' '
end,
'FileIcon',
},
condition = function()
return buffer_not_empty
and has_value(gl.short_line_list, vim.bo.filetype)
end,
highlight = {
fileinfo.get_file_icon,
colors.section_bg,
},
},
}
gls.short_line_left[2] = {
FileName = {
provider = file_name,
condition = buffer_not_empty,
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()

95
lua/plugins.lua Normal file
View File

@ -0,0 +1,95 @@
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
require 'nvim-treesitter.install'.compilers = { 'cl', 'clang' }
require('lspconfig').gdscript.setup{
capabilities = capabilities
}
local cmp = require 'cmp'
cmp.setup({
mapping = {
['<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({ select = true }),
['<TAB>'] = cmp.mapping.confirm({ select = true })
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'emoji' },
{ name = 'path' },
{ name = 'nvim_lua' },
},
experimental = {
ghost_text = true
}
})
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use 'dracula/vim'
use 'kyazdani42/nvim-web-devicons'
use {
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = function()
require('nvim-tree').setup {}
end
}
use 'bryanmylee/vim-colorscheme-icons'
use {
'akinsho/bufferline.nvim',
config = function()
require('bufferline').setup {
options = {
separator_style = 'slant'
}
}
end
}
use {
'NTBBloodbath/galaxyline.nvim',
config = function()
require('galaxyline.themes.minimalist')
end,
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
}
use 'dstein64/nvim-scrollview'
use {
'nvim-telescope/telescope.nvim',
requires = { 'nvim-lua/plenary.nvim' }
}
use 'habamax/vim-godot'
use 'skywind3000/asyncrun.vim'
use 'lervag/wiki.vim'
use 'valloric/listtoggle'
use 'neovim/nvim-lspconfig'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-nvim-lua'
use 'hrsh7th/cmp-emoji'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/nvim-cmp'
use {
'nvim-treesitter/nvim-treesitter',
run = function()
vim.cmd(':TSUpdate')
end
}
use {
'onsails/lspkind-nvim',
config = function()
require('lspkind').init{}
end
}
end)