Compare commits
3 commits
652817cca5
...
2dc8a5a61c
Author | SHA1 | Date | |
---|---|---|---|
2dc8a5a61c | |||
b006557730 | |||
ec664fd566 |
7 changed files with 387 additions and 199 deletions
6
.editorconfig
Normal file
6
.editorconfig
Normal file
|
@ -0,0 +1,6 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
87
config/vim/autoload/crystalline/theme/gruvbox8.vim
Normal file
87
config/vim/autoload/crystalline/theme/gruvbox8.vim
Normal file
|
@ -0,0 +1,87 @@
|
|||
vim9script
|
||||
|
||||
const dark = {
|
||||
bg0: ['#282828', 235],
|
||||
bg1: ['#3c3836', 237],
|
||||
bg2: ['#504945', 239],
|
||||
bg4: ['#7c6f64', 243],
|
||||
|
||||
fg1: ['#ebdbb2', 187],
|
||||
fg4: ['#a89984', 137],
|
||||
|
||||
green: ['#98971a', 100],
|
||||
yellow: ['#d79921', 172],
|
||||
blue: ['#458588', 66],
|
||||
aqua: ['#689d6a', 71],
|
||||
orange: ['#d65d0e', 166],
|
||||
red: ['#fb4934', 203],
|
||||
}
|
||||
|
||||
const light = {
|
||||
bg0: ['#fbf1c7', 230],
|
||||
bg1: ['#ebdbb2', 187],
|
||||
bg2: ['#d5c4a1', 187],
|
||||
bg4: ['#a89984', 137],
|
||||
|
||||
fg1: ['#3c3836', 237],
|
||||
fg4: ['#7c6f64', 243],
|
||||
|
||||
green: ['#98971a', 100],
|
||||
yellow: ['#d79921', 172],
|
||||
blue: ['#458588', 66],
|
||||
aqua: ['#689d6a', 71],
|
||||
orange: ['#d65d0e', 166],
|
||||
red: ['#9d0006', 124],
|
||||
}
|
||||
|
||||
def ToCrystalline(fg: list<any>, bg: list<any>): list<any>
|
||||
return [
|
||||
[fg[1], bg[1]],
|
||||
[fg[0], bg[0]],
|
||||
''
|
||||
]
|
||||
enddef
|
||||
|
||||
def MakeTheme(c: dict<list<any>>): dict<list<any>>
|
||||
var theme = {
|
||||
A: ToCrystalline(c.bg0, c.bg4),
|
||||
B: ToCrystalline(c.fg4, c.bg2),
|
||||
Fill: ToCrystalline(c.fg4, c.bg1),
|
||||
|
||||
InactiveA: ToCrystalline(c.bg4, c.bg1),
|
||||
InactiveB: ToCrystalline(c.bg4, c.bg1),
|
||||
InactiveFill: ToCrystalline(c.bg4, c.bg1),
|
||||
|
||||
InsertModeA: ToCrystalline(c.bg0, c.blue),
|
||||
InsertModeFill: ToCrystalline(c.fg4, c.bg2),
|
||||
|
||||
VisualModeA: ToCrystalline(c.bg0, c.orange),
|
||||
ReplaceModeA: ToCrystalline(c.bg0, c.aqua),
|
||||
ReplaceModeFill: ToCrystalline(c.fg4, c.bg2),
|
||||
TerminalModeA: ToCrystalline(c.bg0, c.green),
|
||||
|
||||
Modified: ToCrystalline(c.red, c.bg1),
|
||||
InsertModeModified: ToCrystalline(c.red, c.bg2),
|
||||
|
||||
TabSel: ToCrystalline(c.bg0, c.fg4),
|
||||
ModifiedSel: ToCrystalline(c.bg1, c.fg4),
|
||||
}
|
||||
|
||||
theme->extend({
|
||||
Tab: theme.Fill,
|
||||
NormalModeModified: theme.Modified,
|
||||
CommandModeModified: theme.Modified,
|
||||
VisualModeModified: theme.Modified,
|
||||
ReplaceModeModified: theme.InsertModeModified,
|
||||
})
|
||||
|
||||
return theme
|
||||
enddef
|
||||
|
||||
export def GetThemeColours(): dict<list<any>>
|
||||
return &background ==# 'dark' ? dark : light
|
||||
enddef
|
||||
|
||||
export def SetTheme(): void
|
||||
GetThemeColours()->MakeTheme()->g:crystalline#GenerateTheme()
|
||||
enddef
|
|
@ -3,66 +3,29 @@ set encoding=utf-8
|
|||
scriptencoding utf-8
|
||||
|
||||
def EnsureDir(dir: string): void
|
||||
if filewritable(dir) != 2
|
||||
mkdir(dir, "p", 0700)
|
||||
endif
|
||||
enddef
|
||||
|
||||
def PrependIfVisible(status: string, symbol: string): string
|
||||
if empty(status)
|
||||
return ''
|
||||
endif
|
||||
return symbol .. status
|
||||
mkdir(dir, "p", 0700)
|
||||
enddef
|
||||
|
||||
# These are really clever - minpac will actually be loaded on the fly only
|
||||
# when you need to update or clean your packages, rather than all the time.
|
||||
command! PackUpdate source $XDG_CONFIG_HOME/vim/plugins.vim | minpac#update()
|
||||
command! PackClean source $XDG_CONFIG_HOME/vim/plugins.vim | minpac#clean()
|
||||
command! PackClean source $XDG_CONFIG_HOME/vim/plugins.vim | minpac#clean()
|
||||
command! PackStatus source $XDG_CONFIG_HOME/vim/plugins.vim | minpac#status()
|
||||
|
||||
# If the pack directory doesn't exist, we haven't installed any packages yet,
|
||||
# so let's call PackUpdate.
|
||||
if !isdirectory($XDG_CACHE_HOME .. '/vim/pack')
|
||||
PackUpdate
|
||||
PackUpdate
|
||||
endif
|
||||
|
||||
if has('gui_running') || has('termguicolors')
|
||||
if $COLORTERM == 'truecolor'
|
||||
&t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
|
||||
&t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
|
||||
endif
|
||||
set termguicolors
|
||||
if $COLORTERM == 'truecolor'
|
||||
&t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
|
||||
&t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
|
||||
endif
|
||||
set termguicolors
|
||||
endif
|
||||
|
||||
g:battery#component_format = '%s %v%%'
|
||||
|
||||
set noshowmode
|
||||
g:lightline = {
|
||||
colorscheme: 'gruvbox8',
|
||||
separator: {left: "\ue0b0", right: "\ue0b2"},
|
||||
subseparator: {left: "\ue0b1", right: "\ue0b3"},
|
||||
active: {
|
||||
left: [['mode', 'paste'], ['git_branch', 'battery'], ['readonly', 'filename', 'modified']],
|
||||
right: [['lineinfo'], ['percent'], ['fileencoding', 'filetype']],
|
||||
},
|
||||
component: {
|
||||
filetype: '%{&ft}[%{&ff}]',
|
||||
lineinfo: '%3l:%-2c',
|
||||
},
|
||||
component_function: {
|
||||
battery: 'battery#component',
|
||||
},
|
||||
component_funcref: {
|
||||
git_branch: () => g:FugitiveHead()->PrependIfVisible(' '),
|
||||
}
|
||||
}
|
||||
|
||||
# Allow Funcrefs, especially lambdas, to be used as lightline components. :)
|
||||
for k in keys(g:lightline.component_funcref)
|
||||
g:lightline.component_function[k] = $'lightline.component_funcref.{k}'
|
||||
endfor
|
||||
|
||||
set background=dark
|
||||
g:gruvbox_transp_bg = 1
|
||||
g:gruvbox_italicize_strings = 0
|
||||
|
@ -73,9 +36,10 @@ colorscheme gruvbox8
|
|||
inoremap jj <Esc>
|
||||
nnoremap <C-t> :Files<CR>
|
||||
|
||||
packadd! editorconfig
|
||||
|
||||
if exists('+belloff')
|
||||
set belloff+=ctrlg
|
||||
set belloff+=ctrlg
|
||||
endif
|
||||
|
||||
set completeopt+=menuone
|
||||
|
@ -85,30 +49,30 @@ set modelines=5
|
|||
set showcmd
|
||||
set wildmode=longest,full
|
||||
if has('patch-8.2.4325')
|
||||
set wildoptions+=pum
|
||||
set wildoptions+=pum
|
||||
endif
|
||||
|
||||
set tabstop=2 shiftwidth=2
|
||||
|
||||
if exists('+breakindent')
|
||||
set breakindent breakindentopt=sbr
|
||||
set breakindent breakindentopt=sbr
|
||||
endif
|
||||
|
||||
if exists('+relativenumber')
|
||||
set relativenumber
|
||||
set relativenumber
|
||||
else
|
||||
set number
|
||||
set number
|
||||
endif
|
||||
|
||||
for dir_name in ['backup', 'swap', 'undo']
|
||||
EnsureDir($XDG_STATE_HOME .. '/vim/' .. dir_name)
|
||||
EnsureDir($XDG_STATE_HOME .. '/vim/' .. dir_name)
|
||||
endfor
|
||||
|
||||
set backupdir=.,$XDG_STATE_HOME/vim/backup
|
||||
set directory=.,$XDG_STATE_HOME/vim/swap
|
||||
if exists('+undofile')
|
||||
set undofile
|
||||
set undodir=$XDG_STATE_HOME/vim/undo
|
||||
set undofile
|
||||
set undodir=$XDG_STATE_HOME/vim/undo
|
||||
endif
|
||||
|
||||
g:csv_no_conceal = 1
|
||||
|
@ -123,11 +87,14 @@ nmap <silent> <C-k> <Plug>(ale_previous_wrap)
|
|||
nmap <silent> <C-j> <Plug>(ale_next_wrap)
|
||||
|
||||
g:mucomplete#can_complete = {
|
||||
default: {
|
||||
omni: (t) => strlen(&l:omnifunc) > 0 && t =~# '\m\k\%(\k\|\.\)$'
|
||||
}
|
||||
default: {
|
||||
omni: (t) => strlen(&l:omnifunc) > 0 && t =~# '\m\k\%(\k\|\.\)$'
|
||||
}
|
||||
}
|
||||
|
||||
import "./statusline.vim"
|
||||
statusline.Init()
|
||||
|
||||
import "./lsp.vim"
|
||||
lsp.LazyConfigure()
|
||||
|
||||
|
|
|
@ -1,161 +1,161 @@
|
|||
vim9script
|
||||
|
||||
const lspServers = [
|
||||
{
|
||||
name: 'dockerfile-langserver',
|
||||
filetype: 'dockerfile',
|
||||
path: expand('~/.local/bin/docker-langserver'),
|
||||
args: ['--stdio'],
|
||||
install: 'npm install -g dockerfile-language-server-nodejs',
|
||||
},
|
||||
{
|
||||
name: 'dockerfile-langserver',
|
||||
filetype: 'dockerfile',
|
||||
path: expand('~/.local/bin/docker-langserver'),
|
||||
args: ['--stdio'],
|
||||
install: 'npm install -g dockerfile-language-server-nodejs',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'lua-language-server',
|
||||
filetype: 'lua',
|
||||
path: '/usr/local/bin/lua-language-server',
|
||||
args: [],
|
||||
install: 'brew install lua-language-server',
|
||||
},
|
||||
{
|
||||
name: 'lua-language-server',
|
||||
filetype: 'lua',
|
||||
path: '/usr/local/bin/lua-language-server',
|
||||
args: [],
|
||||
install: 'brew install lua-language-server',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'taplo',
|
||||
filetype: 'toml',
|
||||
path: '/usr/local/bin/taplo',
|
||||
args: ['lsp', 'stdio'],
|
||||
install: 'brew install taplo',
|
||||
},
|
||||
{
|
||||
name: 'taplo',
|
||||
filetype: 'toml',
|
||||
path: '/usr/local/bin/taplo',
|
||||
args: ['lsp', 'stdio'],
|
||||
install: 'brew install taplo',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'tilt-lsp',
|
||||
filetype: 'bzl',
|
||||
path: '/usr/local/bin/tilt',
|
||||
args: ['lsp', 'start'],
|
||||
install: 'brew install tilt',
|
||||
},
|
||||
{
|
||||
name: 'tilt-lsp',
|
||||
filetype: 'bzl',
|
||||
path: '/usr/local/bin/tilt',
|
||||
args: ['lsp', 'start'],
|
||||
install: 'brew install tilt',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'typescript-language-server',
|
||||
filetype: ['javascript', 'typescript'],
|
||||
path: '/usr/local/bin/typescript-language-server',
|
||||
args: ['--stdio'],
|
||||
install: 'brew install typescript-language-server',
|
||||
},
|
||||
{
|
||||
name: 'typescript-language-server',
|
||||
filetype: ['javascript', 'typescript'],
|
||||
path: '/usr/local/bin/typescript-language-server',
|
||||
args: ['--stdio'],
|
||||
install: 'brew install typescript-language-server',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'phpactor',
|
||||
filetype: 'php',
|
||||
path: expand('~/bin/phpactor'),
|
||||
args: ['language-server'],
|
||||
initializationOptions: {
|
||||
'language_server_configuration.auto_config': false,
|
||||
},
|
||||
install: 'curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar && chmod u+x phpactor && mv phpactor ~/bin',
|
||||
},
|
||||
{
|
||||
name: 'phpactor',
|
||||
filetype: 'php',
|
||||
path: expand('~/bin/phpactor'),
|
||||
args: ['language-server'],
|
||||
initializationOptions: {
|
||||
'language_server_configuration.auto_config': false,
|
||||
},
|
||||
install: 'curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar && chmod u+x phpactor && mv phpactor ~/bin',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'pylsp',
|
||||
filetype: 'python',
|
||||
path: '/usr/local/bin/pylsp',
|
||||
args: [],
|
||||
install: 'brew install python-lsp-server',
|
||||
},
|
||||
{
|
||||
name: 'pylsp',
|
||||
filetype: 'python',
|
||||
path: '/usr/local/bin/pylsp',
|
||||
args: [],
|
||||
install: 'brew install python-lsp-server',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'solargraph',
|
||||
filetype: 'ruby',
|
||||
path: '/usr/local/bin/solargraph',
|
||||
args: ['stdio'],
|
||||
install: 'brew install solargraph',
|
||||
},
|
||||
{
|
||||
name: 'solargraph',
|
||||
filetype: 'ruby',
|
||||
path: '/usr/local/bin/solargraph',
|
||||
args: ['stdio'],
|
||||
install: 'brew install solargraph',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'vim-language-server',
|
||||
filetype: 'vim',
|
||||
path: expand('~/.local/bin/vim-language-server'),
|
||||
args: ['--stdio'],
|
||||
install: 'npm install -g vim-language-server',
|
||||
},
|
||||
{
|
||||
name: 'vim-language-server',
|
||||
filetype: 'vim',
|
||||
path: expand('~/.local/bin/vim-language-server'),
|
||||
args: ['--stdio'],
|
||||
install: 'npm install -g vim-language-server',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'vscode-json-language-server',
|
||||
filetype: ['json', 'jsonc'],
|
||||
path: expand('~/.local/bin/vscode-json-language-server'),
|
||||
args: ['--stdio'],
|
||||
workspaceConfig: {json: {
|
||||
format: {enable: true},
|
||||
{
|
||||
name: 'vscode-json-language-server',
|
||||
filetype: ['json', 'jsonc'],
|
||||
path: expand('~/.local/bin/vscode-json-language-server'),
|
||||
args: ['--stdio'],
|
||||
workspaceConfig: {json: {
|
||||
format: {enable: true},
|
||||
validate: {enable: true},
|
||||
schemas: g:SchemaStore#Schemata(),
|
||||
}},
|
||||
install: 'npm install -g vscode-langservers-extracted',
|
||||
},
|
||||
schemas: g:SchemaStore#Schemata(),
|
||||
}},
|
||||
install: 'npm install -g vscode-langservers-extracted',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'yaml-language-server',
|
||||
filetype: 'yaml',
|
||||
path: expand('~/.local/bin/yaml-language-server'),
|
||||
args: ['--stdio'],
|
||||
workspaceConfig: {yaml: {
|
||||
format: {enable: true, singleQuote: true},
|
||||
schemaStore: {enable: true, url: 'https://www.schemastore.org/api/json/catalog.json'},
|
||||
}},
|
||||
install: 'npm install -g yaml-language-server',
|
||||
},
|
||||
{
|
||||
name: 'yaml-language-server',
|
||||
filetype: 'yaml',
|
||||
path: expand('~/.local/bin/yaml-language-server'),
|
||||
args: ['--stdio'],
|
||||
workspaceConfig: {yaml: {
|
||||
format: {enable: true, singleQuote: true},
|
||||
schemaStore: {enable: true, url: 'https://www.schemastore.org/api/json/catalog.json'},
|
||||
}},
|
||||
install: 'npm install -g yaml-language-server',
|
||||
},
|
||||
]
|
||||
|
||||
const lspOptions = {
|
||||
aleSupport: true,
|
||||
ignoreMissingServer: true,
|
||||
aleSupport: true,
|
||||
ignoreMissingServer: true,
|
||||
}
|
||||
|
||||
command! -nargs=0 -bar LspInstall Install()
|
||||
|
||||
def InstalledServers(): list<dict<any>>
|
||||
return lspServers->deepcopy()->filter((_, server): bool => executable(server.path) == 1)
|
||||
return lspServers->deepcopy()->filter((_, server): bool => executable(server.path) == 1)
|
||||
enddef
|
||||
|
||||
def MissingServers(): list<dict<any>>
|
||||
return lspServers->deepcopy()->filter((_, server): bool => executable(server.path) == 0)
|
||||
return lspServers->deepcopy()->filter((_, server): bool => executable(server.path) == 0)
|
||||
enddef
|
||||
|
||||
export def LazyConfigure(): void
|
||||
autocmd VimEnter * ++once Configure()
|
||||
autocmd VimEnter * ++once Configure()
|
||||
enddef
|
||||
|
||||
export def Configure(): void
|
||||
final installedServers = InstalledServers()
|
||||
if len(lspServers) != len(installedServers)
|
||||
echo $'{len(lspServers) - len(installedServers)} language servers are configured, but not installed. You may want to run :LspInstall.'
|
||||
endif
|
||||
g:LspAddServer(installedServers)
|
||||
g:LspOptionsSet(lspOptions)
|
||||
final installedServers = InstalledServers()
|
||||
if len(lspServers) != len(installedServers)
|
||||
echo $'{len(lspServers) - len(installedServers)} language servers are configured, but not installed. You may want to run :LspInstall.'
|
||||
endif
|
||||
g:LspAddServer(installedServers)
|
||||
g:LspOptionsSet(lspOptions)
|
||||
enddef
|
||||
|
||||
export def Install(): void
|
||||
const missingServers = MissingServers()
|
||||
if empty(missingServers)
|
||||
echo $"All {len(lspServers)} configured language servers are already installed."
|
||||
return
|
||||
endif
|
||||
const missingServers = MissingServers()
|
||||
if empty(missingServers)
|
||||
echo $"All {len(lspServers)} configured language servers are already installed."
|
||||
return
|
||||
endif
|
||||
|
||||
# The installScript runs every missing server's install command, regardless
|
||||
# of whether any fail in the process. The script's exit status is the number
|
||||
# of failed installations.
|
||||
const installScript = "failed=0\n" .. missingServers->copy()
|
||||
->map((_, server): string => $"\{ {server.install}; \} || failed=$((failed + 1))")
|
||||
->join("\n") .. "\nexit $failed\n"
|
||||
# The installScript runs every missing server's install command, regardless
|
||||
# of whether any fail in the process. The script's exit status is the number
|
||||
# of failed installations.
|
||||
const installScript = "failed=0\n" .. missingServers->copy()
|
||||
->map((_, server): string => $"\{ {server.install}; \} || failed=$((failed + 1))")
|
||||
->join("\n") .. "\nexit $failed\n"
|
||||
|
||||
const term = term_start('sh', {exit_cb: (job: job, status: number): void => {
|
||||
# If any installations failed, keep the terminal window open so we can
|
||||
# troubleshoot. If they all worked fine, close the terminal and reload the
|
||||
# LSP configuration.
|
||||
if status == 0
|
||||
execute 'bdelete' job->ch_getbufnr('out')
|
||||
Configure()
|
||||
endif
|
||||
}})
|
||||
const term = term_start('sh', {exit_cb: (job: job, status: number): void => {
|
||||
# If any installations failed, keep the terminal window open so we can
|
||||
# troubleshoot. If they all worked fine, close the terminal and reload the
|
||||
# LSP configuration.
|
||||
if status == 0
|
||||
execute 'bdelete' job->ch_getbufnr('out')
|
||||
Configure()
|
||||
endif
|
||||
}})
|
||||
|
||||
# We prefer term_sendkeys() over sh -c because that will display each
|
||||
# command in the terminal as it's being executed, making it easier to
|
||||
# understand exactly what the install script is doing.
|
||||
term->term_sendkeys(installScript)
|
||||
# We prefer term_sendkeys() over sh -c because that will display each
|
||||
# command in the terminal as it's being executed, making it easier to
|
||||
# understand exactly what the install script is doing.
|
||||
term->term_sendkeys(installScript)
|
||||
enddef
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
vim9script
|
||||
silent! packadd minpac
|
||||
if !exists('g:loaded_minpac')
|
||||
silent !git clone https://github.com/k-takata/minpac.git $XDG_CACHE_HOME/vim/pack/minpac/opt/minpac
|
||||
augroup minpac {
|
||||
autocmd!
|
||||
autocmd VimEnter * call minpac#update()
|
||||
}
|
||||
silent !git clone https://github.com/k-takata/minpac.git $XDG_CACHE_HOME/vim/pack/minpac/opt/minpac
|
||||
augroup minpac {
|
||||
autocmd!
|
||||
autocmd VimEnter * call minpac#update()
|
||||
}
|
||||
endif
|
||||
packadd minpac
|
||||
|
||||
|
@ -16,8 +16,11 @@ minpac#add('prabirshrestha/async.vim')
|
|||
|
||||
minpac#add('lifepillar/vim-gruvbox8')
|
||||
|
||||
if !isdirectory($VIMRUNTIME .. '/pack/dist/opt/editorconfig')
|
||||
minpac#add('editorconfig/editorconfig-vim')
|
||||
endif
|
||||
|
||||
minpac#add('direnv/direnv.vim')
|
||||
minpac#add('editorconfig/editorconfig-vim')
|
||||
minpac#add('godlygeek/tabular')
|
||||
minpac#add('jamessan/vim-gnupg')
|
||||
minpac#add('junegunn/vim-easy-align')
|
||||
|
@ -46,8 +49,9 @@ minpac#add('w0rp/ale')
|
|||
minpac#add('yegappan/lsp')
|
||||
minpac#add('00dani/SchemaStore.vim')
|
||||
|
||||
minpac#add('itchyny/lightline.vim')
|
||||
minpac#add('rbong/vim-crystalline')
|
||||
minpac#add('lambdalisue/battery.vim')
|
||||
minpac#add('lambdalisue/nerdfont.vim')
|
||||
|
||||
minpac#add('alvan/vim-closetag')
|
||||
minpac#add('LaTeX-Box-Team/LaTeX-Box')
|
||||
|
@ -70,7 +74,7 @@ minpac#add('fpob/nette.vim')
|
|||
minpac#add('leafOfTree/vim-svelte-plugin')
|
||||
|
||||
if executable('task')
|
||||
minpac#add('farseer90718/vim-taskwarrior')
|
||||
minpac#add('farseer90718/vim-taskwarrior')
|
||||
endif
|
||||
|
||||
minpac#add('pedrohdz/vim-yaml-folds')
|
||||
|
@ -79,8 +83,8 @@ minpac#add('alx741/yesod.vim')
|
|||
minpac#add('pbrisbin/vim-syntax-shakespeare')
|
||||
|
||||
if has('macunix')
|
||||
minpac#add('rizzatti/dash.vim')
|
||||
# We rename this plugin to make sure it loads AFTER vim-polyglot,
|
||||
# since it won't work properly if it's loaded first.
|
||||
minpac#add('itspriddle/vim-marked', {name: 'zzvim-marked'})
|
||||
minpac#add('rizzatti/dash.vim')
|
||||
# We rename this plugin to make sure it loads AFTER vim-polyglot,
|
||||
# since it won't work properly if it's loaded first.
|
||||
minpac#add('itspriddle/vim-marked', {name: 'zzvim-marked'})
|
||||
endif
|
||||
|
|
124
config/vim/statusline.vim
Normal file
124
config/vim/statusline.vim
Normal file
|
@ -0,0 +1,124 @@
|
|||
vim9script
|
||||
|
||||
import autoload ($XDG_CACHE_HOME .. '/vim/pack/minpac/start/vim-crystalline/autoload/crystalline.vim') as cr
|
||||
|
||||
def PrependIfVisible(status: string, prefix: string): string
|
||||
if empty(status)
|
||||
return ''
|
||||
endif
|
||||
return prefix .. status
|
||||
enddef
|
||||
|
||||
def AppendIfVisible(status: string, affix: string): string
|
||||
if empty(status)
|
||||
return ''
|
||||
endif
|
||||
return status .. affix
|
||||
enddef
|
||||
|
||||
def StatuslineSection(seps: number, group: string, components: list<string>): string
|
||||
const hiGroup = cr.ModeGroup(group)
|
||||
return components->copy()->filter((_, s) => s != '')
|
||||
->join(' ' .. cr.Sep(seps, hiGroup, hiGroup) .. ' ')
|
||||
enddef
|
||||
|
||||
def GitStatus(): string
|
||||
if empty(g:FugitiveGitDir())
|
||||
return ''
|
||||
endif
|
||||
|
||||
const branch = g:FugitiveHead()->PrependIfVisible("\ue0a0 ") # nf-pl-branch
|
||||
if !empty(branch)
|
||||
return branch
|
||||
endif
|
||||
|
||||
return g:FugitiveHead(7)
|
||||
->PrependIfVisible("\Uf135e (") # nf-md-head
|
||||
->AppendIfVisible(")")
|
||||
enddef
|
||||
|
||||
def StatuslineLeft(window: number, inactive: bool): string
|
||||
const bufnr = window->winbufnr()
|
||||
const b = bufnr->getbufvar('&')
|
||||
const fileName = [
|
||||
bufname(bufnr)->g:nerdfont#find()->AppendIfVisible(' '),
|
||||
b.buftype == '' ? '%t' : '%f',
|
||||
b.modifiable && b.modified ? cr.ModeHiItem('Modified') .. '+' .. cr.ModeHiItem('Fill') : '',
|
||||
b.readonly ? " \uf023" : '', # nf-fa-lock
|
||||
]->join('')
|
||||
if inactive
|
||||
return ' ' .. fileName
|
||||
endif
|
||||
|
||||
const info = StatuslineSection(0, 'B', [
|
||||
GitStatus(),
|
||||
g:battery#component_escaped(),
|
||||
])->AppendIfVisible(' ' .. cr.Sep(0, cr.ModeGroup('B'), cr.ModeGroup('Fill')))
|
||||
const vimMode = cr.ModeSection(0, 'A', empty(info) ? 'Fill' : 'B')
|
||||
|
||||
return join([vimMode, info, fileName])
|
||||
enddef
|
||||
|
||||
def StatuslineRight(window: number, inactive: bool): string
|
||||
const percent = '%3p%%'
|
||||
const lineInfo = '%3l:%-2c'
|
||||
const fileType = '%{&ft}[%{&ff}]'
|
||||
if inactive
|
||||
return StatuslineSection(1, 'Fill', [fileType, percent, lineInfo])
|
||||
endif
|
||||
|
||||
const fileEncoding = &fileencoding
|
||||
const fileInfo = StatuslineSection(1, 'Fill', [fileEncoding, fileType])
|
||||
|
||||
const prettyPercent = cr.Sep(1, cr.ModeGroup('Fill'), cr.ModeGroup('B')) .. ' ' .. percent
|
||||
const prettyLineInfo = cr.Sep(1, cr.ModeGroup('B'), cr.ModeGroup('A')) .. lineInfo
|
||||
|
||||
return join([fileInfo, prettyPercent, prettyLineInfo])
|
||||
enddef
|
||||
|
||||
def ConfigurePlugins(): void
|
||||
g:battery#component_format = '%s %v%%'
|
||||
g:nerdfont#default = ''
|
||||
g:crystalline_theme = 'gruvbox8'
|
||||
enddef
|
||||
|
||||
def InitStatus(): void
|
||||
def g:CrystallineStatuslineFn(window: number): string
|
||||
const inactive = window != winnr()
|
||||
const statusLeft = StatuslineLeft(window, inactive)
|
||||
const statusRight = StatuslineRight(window, inactive)
|
||||
|
||||
return $'{statusLeft}%={statusRight}'
|
||||
enddef
|
||||
enddef
|
||||
|
||||
def InitTab()
|
||||
g:crystalline_tab_mod = ''
|
||||
def g:CrystallineTablineFn(): string
|
||||
return cr.DefaultTabline({auto_prefix_groups: false})
|
||||
enddef
|
||||
|
||||
def g:CrystallineTabFn(tabnr: number, bufnr: number, maxWidth: number, isSel: bool): list<any>
|
||||
var [tabDisplay, width] = cr.DefaultTab(tabnr, bufnr, maxWidth, isSel)
|
||||
|
||||
if bufnr->getbufvar('&modified')
|
||||
const sel = isSel ? 'Sel' : ''
|
||||
tabDisplay ..= cr.HiItem($'Modified{sel}') .. '+' .. cr.HiItem($'Tab{sel}') .. ' '
|
||||
width += 2
|
||||
endif
|
||||
|
||||
const icon = bufname(bufnr)->g:nerdfont#find()->PrependIfVisible(' ')
|
||||
if width + strchars(icon) >= maxWidth
|
||||
return [tabDisplay, width]
|
||||
endif
|
||||
|
||||
return [icon .. tabDisplay, width + strchars(icon)]
|
||||
enddef
|
||||
enddef
|
||||
|
||||
export def Init(): void
|
||||
InitStatus()
|
||||
InitTab()
|
||||
ConfigurePlugins()
|
||||
set noshowmode
|
||||
enddef
|
16
vimrc
16
vimrc
|
@ -1,20 +1,20 @@
|
|||
vim9script
|
||||
const xdg = {
|
||||
XDG_CONFIG_HOME: '~/.config',
|
||||
XDG_CACHE_HOME: '~/.cache',
|
||||
XDG_DATA_HOME: '~/.local/share',
|
||||
XDG_STATE_HOME: '~/.local/state',
|
||||
XDG_CONFIG_HOME: '~/.config',
|
||||
XDG_CACHE_HOME: '~/.cache',
|
||||
XDG_DATA_HOME: '~/.local/share',
|
||||
XDG_STATE_HOME: '~/.local/state',
|
||||
}
|
||||
for [key, default] in items(xdg)
|
||||
if !has_key(environ(), key)
|
||||
setenv(key, expand(default))
|
||||
endif
|
||||
if !has_key(environ(), key)
|
||||
setenv(key, expand(default))
|
||||
endif
|
||||
endfor
|
||||
|
||||
set runtimepath=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$XDG_CONFIG_HOME/vim/after,$XDG_CACHE_HOME/vim/after
|
||||
set viminfo+=n$XDG_STATE_HOME/vim/viminfo
|
||||
if exists('+packpath')
|
||||
set packpath^=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim
|
||||
set packpath^=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim
|
||||
endif
|
||||
g:netrw_home = $XDG_CACHE_HOME .. '/vim/netrw'
|
||||
|
||||
|
|
Loading…
Reference in a new issue