Switch to Lua once and for all\nTODO: Apply sane defaults, add nvim-cmp, configure lspsaga, overhaul lualine contents, switch to treesitter theme, config treesitter, config telescope, add luasnip

This commit is contained in:
David Holland 2022-05-30 22:20:50 +02:00
parent dc4a46d6e2
commit 623ef3a48d
Signed by: DustVoice
GPG Key ID: 47068995A14EDCA9
12 changed files with 1406 additions and 1214 deletions

5
.gitignore vendored
View File

@ -7,10 +7,13 @@
!/coc-settings.json
!/custom.vim.example
!/ginit.vim
!/init.lua
!/init.vim
!/platform.vim.example
!/TODO.txt
!/colors/
!/autoload/
!/colors/
!/lua/
!/pack/
!/spell/

8
init.lua Normal file
View File

@ -0,0 +1,8 @@
require('plugins')
require('post_plugins')
require('platform')
require('custom')
require('settings')
require('plugin_options')
require('utilities')
require('keymaps')

1213
init.vim

File diff suppressed because it is too large Load Diff

4
lua/custom/example.lua Normal file
View File

@ -0,0 +1,4 @@
--Here you can define your own custom settings like
--vim.g.use_sound = true
--vim.g.use_autocomplete = true
--vim.g.use_coc = true

28
lua/keymaps.lua Normal file
View File

@ -0,0 +1,28 @@
-- ===
-- General maps
-- ===
vim.keymap.set('n', '<leader>cd', ':cd %:p:h<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<leader>lcd', ':lcd %:p:h<CR>', { noremap = true, silent = true })
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { noremap = true })
vim.keymap.set('n', '<leader>+', '<C-W>+', { noremap = true })
vim.keymap.set('n', '<leader>-', '<C-W>-', { noremap = true })
vim.keymap.set('n', '<leader><', '<C-W><', { noremap = true })
vim.keymap.set('n', '<leader>>', '<C-W>>', { noremap = true })
vim.keymap.set('n', '<leader>_', '<C-W>_', { noremap = true })
vim.keymap.set('n', '<leader><BAR>', '<C-W><BAR>', { noremap = true })
vim.keymap.set('n', '<leader>=', '<C-W>=', { noremap = true })
vim.keymap.set('n', '<leader>T', '<C-W>T', { noremap = true })
vim.keymap.set('n', '<leader>h', ':noh<CR>')
vim.keymap.set('n', '<leader>.', ':bnext<CR>')
vim.keymap.set('n', '<leader>,', ':bprev<CR>')
-- ===
-- ===
-- Background
-- ===
vim.keymap.set('n', '<leader>bg', ':let &background = ( &background == "dark"? "light" : "dark" )<CR>')
-- ===

3
lua/platform/example.lua Normal file
View File

@ -0,0 +1,3 @@
" Possible options: windows, windows_portable, linux, termux, linux_qt, arch
" Note that linux_qt and arch have not been implemented yet
vim.g.platform = "linux"

725
lua/plugin_options.lua Normal file
View File

@ -0,0 +1,725 @@
-- ===
-- clang-format
-- ===
if vim.g.use_clang_format == true then
vim.g['clang_format#detect_style_file'] = 1
vim.g['clang_format#enable_fallback_style'] = 1
vim.g['clang_format#style'] = "Microsoft"
vim.g['clang_format#style_options'] = {
BasedOnStyle = "Microsoft",
AccessModifierOffset = -4,
AlignAfterOpenBracket = "Align",
AlignConsecutiveAssignments = "false",
AlignConsecutiveDeclarations = "false",
AlignEscapedNewlinesLeft = "false",
AlignOperands = "true",
AlignTrailingComments = "false",
AllowAllParametersOfDeclarationOnNextLine = "false",
AllowShortBlocksOnASingleLine = "false",
AllowShortCaseLabelsOnASingleLine = "false",
AllowShortFunctionsOnASingleLine = "All",
AllowShortifStatementsOnASingleLine = "false",
AllowShortLoopsOnASingleLine = "false",
AlwaysBreakAfterDefinitionReturnType = "None",
AlwaysBreakAfterReturnType = "None",
AlwaysBreakBeforeMultilineStrings = "false",
AlwaysBreakTemplateDeclarations = "true",
BinPackArguments = "false",
BinPackParameters = "false",
BreakAfterJavaFieldAnnotations = "false",
BreakBeforeBinaryOperators = "NonAssignment",
BreakBeforeBraces = "Allman",
BreakBeforeTernaryOperators = "true",
BreakConstructorInitializersBeforeComma = "false",
BreakStringLiterals = "false",
ColumnLimit = 0,
ConstructorInitializerAllOnOneLineOrOnePerLine = "true",
ConstructorInitializerIndentWidth = 4,
ContinuationIndentWidth = 4,
Cpp11BracedListStyle = "false",
DerivePointerAlignment = "false",
DisableFormat = "false",
ExperimentalAutoDetectBinPacking = "false",
IndentCaseLabels = "true",
IndentWidth = 4,
IndentWrappedFunctionNames = "true",
KeepEmptyLinesAtTheStartOfBlocks = "false",
Language = "Cpp",
MaxEmptyLinesToKeep = 1,
NamespaceIndentation = "Inner",
PointerAlignment = "Left",
ReflowComments = "false",
SortIncludes = "true",
SpaceAfterCStyleCast = "true",
SpaceBeforeAssignmentOperators = "true",
SpaceBeforeParens = "ControlStatements",
SpaceInEmptyParentheses = "false",
SpacesInAngles = "false",
SpacesInCStyleCastParentheses = "false",
SpacesInContainerLiterals = "true",
SpacesInParentheses = "false",
SpacesInSquareBrackets = "false",
Standard = "Cpp11",
TabWidth = 4,
UseTab = "Never"
}
vim.g['clang_format#auto_format'] = 1
vim.g['clang_format#auto_format_on_insert_leave'] = 0
vim.cmd([[
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :ClangFormat<CR>
]])
vim.keymap.set('n', '<leader>ct', ':ClangFormatAutoToggle<cr>')
end
-- ===
-- ===
-- Indentguides config
-- ===
if vim.g.use_indentguides then
vim.g.indentguides_spacechar = ''
vim.g.indentguides_tabchar = '|'
vim.g.indentguides_firstlevel = 1
end
-- ===
-- ===
-- Comfortable Motion setup
-- ===
if vim.g.use_comfortable_motion == true then
vim.g.comfortable_motion_no_default_key_mappings = 1
vim.g.comfortable_motion_impulse_multiplier = 1 -- Feel free to increase/decrease this value.
vim.keymap.set('n', '<C-e>', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 1)<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<C-y>', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -1)<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<C-u>', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 2)<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<C-d>', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -2)<CR>', { noremap = true, silent = true })
end
-- ===
-- ===
-- Disable polyglot for latex files
-- ===
if vim.g.use_polyglot == true then
vim.g.vim_markdown_conceal = 0
end
-- ===
-- ===
-- Setup vimtex
-- ===
if vim.g.use_vimtex == true then
vim.g.polyglot_disabled = { "latex", "tex" }
vim.g.tex_flavor = "latex"
--vim.g.vimtex_syntax_packages = { hyperref = { load = 2 }, listings = { load:2 }, luacode = { load = 2 }, minted = {load = 2}}
vim.g.vimtex_format_enabled = 1
vim.g.vimtex_indent_enabled = 1
--let g:vimtex_indent_ignored_envs = ["document"]
--let g:vimtex_syntax_minted = [{"lang":"text"}, {"lang":"console"}]
vim.g.vimtex_compiler_enabled = 0
--let g:vimtex_compiler_latexmk = {"backend":"nvim", "background":1, "build_dir":"", "callback":1, "continuous":1, "executable":"latexmk", "options":["-verbose", "-file-line-error", "-synctex=1", "-interaction=nonstopmode", "-lualatex", "-shell-escape"]}
--let g:vimtex_quickfix_mode = 1
--let g:vimtex_quickfix_open_on_warning = 0
vim.g.vimtex_view_enabled = 0
vim.g.vimtex_view_general_viewer = ""
--[[
if g:platform ==? "windows" || g:platform ==? "windows_portable" then
"let g:vimtex_view_enabled = 1
"let g:vimtex_view_general_viewer = 'SumatraPDF'
"let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
"let g:vimtex_view_general_options_latexmk = '-reuse-instance'
"elseif g:platform ==? "termux" then
"let g:vimtex_view_enabled = 1
"let g:vimtex_view_general_viewer = 'termux-open'
"else
"let g:vimtex_view_enabled = 0
"let g:vimtex_view_general_viewer = ''
"end
"let g:vimtex_fold_enabled=1
--]]
vim.cmd('au BufNewFile,BufRead *.cls call execute("set filetype=tex")')
end
-- ===
-- ===
-- Setup javacomplete
-- ===
if vim.g.use_javacomplete == true then
vim.cmd('autocmd FileType java setlocal omnifunc=javacomplete#Complete')
end
-- ===
-- ===
-- Setup deoplete
-- ===
if vim.g.use_autocomplete == 2 then
vim.g['deoplete#enable_at_startup'] = true
end
-- ===
-- ===
-- Setup YouCompleteMe
-- ===
if vim.g.use_autocomplete == 3 then
vim.keymap.set('n', '<leader>ygg', ':YcmCompleter GoToImprecise<CR>', { noremap = true })
vim.keymap.set('n', '<leader>yg', ':YcmCompleter GoTo<CR>', { noremap = true })
vim.keymap.set('n', '<leader>ytt', ':YcmCompleter GetTypeImprecise<CR>', { noremap = true })
vim.keymap.set('n', '<leader>yt', ':YcmCompleter GetType<CR>', { noremap = true })
vim.keymap.set('n', '<leader>ydd', ':YcmCompleter GetDocImprecise<CR>', { noremap = true })
vim.keymap.set('n', '<leader>yd', ':YcmCompleter GetDoc<CR>', { noremap = true })
vim.keymap.set('n', '<leader>yf', ':YcmCompleter FixIt<CR>', { noremap = true })
vim.keymap.set('n', '<leader>yq', ':YcmDiags<CR>', { noremap = true })
vim.keymap.set('n', '<leader>yy', ':YcmCompleter<Space>', { noremap = true })
vim.keymap.set('n', '<leader>yr', ':YcmRestartServer<CR>', { noremap = true })
end
-- ===
-- ===
-- Setup CoC
-- ===
if vim.g.use_coc == true then
vim.opt.updatetime = 300
vim.opt.shortmess = vim.opt.shortmess + "c"
vim.opt.signcolumn = "yes"
vim.keymap.set('i', '<C-Space>', 'coc#refresh()', { noremap = true })
vim.keymap.set('n', '[g', '<Plug>(coc-diagnostic-prev)', { silent = true })
vim.keymap.set('n', ']g', '<Plug>(coc-diagnostic-next)', { silent = true })
vim.keymap.set('n', 'gd', '<Plug>(coc-definition)', { silent = true })
vim.keymap.set('n', 'gy', '<Plug>(coc-type-definition)', { silent = true })
vim.keymap.set('n', 'gi', '<Plug>(coc-implementation)', { silent = true })
vim.keymap.set('n', 'gr', '<Plug>(coc-references)', { silent = true })
vim.keymap.set('n', '<silent> K', ':call <SID>show_documentation()<CR>', { noremap = true })
vim.cmd([[
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0) then
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready()) then
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
end
endfunction
autocmd CursorHold * silent call CocActionAsync('highlight')
]])
vim.keymap.set('n', '<leader>rn', '<Plug>(coc-rename)')
vim.keymap.set('x', '<leader>f ', '<Plug>(coc-format-selected)')
vim.keymap.set('n', '<leader>f ', '<Plug>(coc-format-selected)')
vim.keymap.set('n', '<leader>ac ', '<Plug>(coc-codeaction)')
vim.keymap.set('n', '<leader>qf ', '<Plug>(coc-fix-current)')
vim.cmd([[
if has('nvim-0.4.0') || has('patch-8.2.0750') then
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
end
command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
]])
vim.keymap.set('n', '<leader>y', ':<C-u>CocList -A --normal yank<CR>', { noremap = true, silent = true })
vim.g.coc_global_extensions = { "coc-clangd", "coc-cmake", "coc-html", "coc-html-css-support", "coc-java", "coc-json", "coc-lists", "coc-markdownlint", "coc-omnisharp", "coc-prettier", "coc-pyright", "coc-rust-analyzer", "coc-sh", "coc-snippets", "coc-xml", "coc-yank" }
end
-- ===
-- ===
-- Setup fswitch
-- ===
if vim.g.use_fswitch == true then
vim.keymap.set('n', '<leader>s', ':FSHere<CR>', { noremap = true })
end
-- ===
-- ===
-- Setup python
-- ===
if vim.g.use_python == true then
vim.g.table_mode_corner_corner = "+"
vim.g.table_mode_header_fillchar = "="
end
-- ===
-- ===
-- Setup airline
-- ===
if vim.g.use_airline == true then
vim.g.airline_powerline_fonts = true
if not vim.g.airline_symbols then
vim.g.airline_symbols = {}
if vim.g.use_font == true then
vim.g.airline_left_sep = ""
vim.g.airline_right_sep = ""
vim.g.airline_symbols.linenr = ""
vim.g.airline_symbols.linenr = ""
vim.g.airline_symbols.linenr = ""
vim.g.airline_symbols.branch = ""
vim.g.airline_symbols.paste = "ρ"
vim.g.airline_symbols.paste = "Þ"
vim.g.airline_symbols.paste = ""
vim.g.airline_symbols.whitespace = "Ξ"
end
end
-- ===
-- unicode symbols
-- ===
--[[
vim.g.airline_left_sep = "»"
vim.g.airline_left_sep = ""
vim.g.airline_right_sep = "«"
vim.g.airline_right_sep = ""
vim.g.airline_symbols.linenr = ""
vim.g.airline_symbols.linenr = ""
vim.g.airline_symbols.linenr = ""
vim.g.airline_symbols.branch = ""
vim.g.airline_symbols.paste = "ρ"
vim.g.airline_symbols.paste = "Þ"
vim.g.airline_symbols.paste = ""
vim.g.airline_symbols.whitespace = "Ξ"
--]]
-- ===
-- ===
-- airline symbols
-- ===
--[[
vim.g.airline_left_sep = ""
vim.g.airline_left_alt_sep = ""
vim.g.airline_right_sep = ""
vim.g.airline_right_alt_sep = ""
vim.g.airline_symbols.branch = ""
vim.g.airline_symbols.readonly = ""
vim.g.airline_symbols.linenr = ""
--]]
-- ===
vim.g.airline_theme = "dracula"
end
-- ===
-- ===
-- Setup sound
-- ===
if vim.g.use_sound == true then
vim.cmd([[
call orchestra#prelude()
call orchestra#set_tune('bubbletrouble')
]])
end
-- ===
-- ===
-- Setup livedown
-- ===
if vim.g.use_livedown == true then
vim.g.livedown_autorun = 0
vim.g.livedown_open = 1
vim.g.livedown_port = 1337
vim.g.livedown_browser = "firefox -P livedown"
vim.g.confirm_new_file = 1
vim.g.wiki_history = {}
vim.keymap.set('n', '<leader>m', ':LivedownToggle<CR>')
end
-- ===
-- ===
-- Setup Nerdtree
-- ===
if vim.g.use_nerdtree == true then
vim.keymap.set({ 'n', 'v', 'o' }, 'map <leader>n', ':NERDTreeToggle<CR>')
end
-- ===
-- ===
-- Setup pandoc
-- ===
if vim.g.use_pandoc == true then
vim.g['pandoc#syntax#conceal#use'] = 0
vim.g['pandoc#formatting#mode'] = "sa"
vim.g['pandoc#formatting#smart_autoformat_on_cursormoved'] = 1
vim.g.data = {}
vim.cmd([[
function! g:JobHandler(job_id, data, event)
if a:event == 'stdout' || a:event == 'stderr' then
echom '>> ' . substitute(join(a:data), "\^M", "\r", "g")
else
echom 'Job ' . a:job_id . ' finished'
let index = 0
while index < len(g:jobs)
let item = g:jobs[index]
if item == a:job_id
call remove(g:jobs, index)
endif
let index = index + 1
endwhile
if string(a:data) != "0"
echoerr 'Program terminated with exit code ' . string(a:data)
endif
endif
"call append(line('$'), str)
endfunction
]])
vim.g.callbacks = {
on_stdout = 'function("g:JobHandler")',
on_stderr = 'function("g:JobHandler")',
on_exit = 'function("g:JobHandler")'
}
vim.g.callbacks_no_out = {
on_exit = 'function("g:JobHandler")'
}
-- function! Stdout(job_id, data, event)
-- echom 'Job ' . a:job_id . ': >>' . join(a:data)
-- " echom 'stdout: ' . a:data[0]
-- endfunction
-- function! Stderr(job_id, data, event)
-- echoerr 'Job ' . a:job_id . ': >>' . join(a:data)
-- endfunction
-- function! PrintFinished(job_id, data, event)
-- echom 'Job ' . a:job_id . ' finished with exit code: ' . string(a:data)
-- endfunction
vim.cmd([[
function! OpenPdf()
if g:use_async==1 then
let pdf_path = ""
if g:latex_use_outdir==1 then
let pdf_path = expand('%:r') . "_" . g:latex_outdir . "/" . expand('%:t:r') . ".pdf"
else
let pdf_path = expand('%:r') . ".pdf"
end
let pdf_job = jobstart(g:pdf_viewer . " " . pdf_path)
echom "Started PDF-Viewer with job_id " . pdf_job
"execute("AsyncRun " . g:pdf_viewer . " " . expand('%:r') . ".pdf")
let g:open_pdf=0
else
execute("!" . g:pdf_viewer. " " . expand('%:r') . ".pdf")
end
endfunction
function! ConvertPandoc(attr)
let command = ""
if a:attr == "md-to-pdf" then
let command = "pandoc -s " . @% . " --from=markdown+escaped_line_breaks -o " . expand('%:r') . ".pdf"
elseif a:attr == "md-html-to-pdf" then
let command = "pandoc --katex --highlight-style=zenburn -t html5 --css=file:///D:/Pandoc/katex_style.css " . @% . " -o " . expand('%:r') . ".pdf"
elseif a:attr == "md-to-html" then
let command = "pandoc " . @% . " -s --katex --css=file:///D:/Pandoc/katex_style.css -o " . expand('%:r') . ".html"
elseif a:attr == "latex-to-pdf" then
let command = "pandoc " . @% . " -s -o " . expand('%:r') . ".pdf"
end
" if g:use_async==1 then
" execute("AsyncRun " . command)
" else
"let g:pandoc#command#autoexec_command="call jobstart('pandoc -s " . @% . " --from=markdown -o " . expand('%:r') . ".pdf')"
if g:use_async==1 then
" let g:current_job = jobstart('pandoc -s ' . expand('%') . ' --from=markdown -o ' . expand('%:r') . '.pdf', {'out_io': 'buffer', 'out_name': g:pandoc_output})
" let g:current_job = jobstart(command, {'out_io': 'buffer', 'out_name': g:pandoc_output})
" let g:current_job = jobstart(command, {'on_stdout': function('Stdout'), 'on_stderr': function('Stdout'), 'on_exit': function('PrintFinished')})
"
if len(g:jobs) > 0 then
let index = 0
while index < len(g:jobs)
let item = g:jobs[index]
call jobstop(item)
let index = index + 1
endwhile
end
let current_job = jobstart(command, g:callbacks)
call insert(g:jobs, current_job)
echom 'Running ' . command . ' with Job-Nr. ' . current_job
else
execute("!" . command)
echom "Compilation finished"
end
" end
if g:open_pdf==1 then
call OpenPdf() normal <CR>
end
endfunction
function! g:ExitedWithCode(job_id, data, event)
echom "Job " . a:job_id . " exited with code: " . string(a:data)
endfunction
function! ConvertPandocPdfLatexDebug()
let command = "pandoc " . @% . " -s -o " . expand('%:r') . ".tex"
let output = ""
if g:latex_use_outdir==1 then
let output = "-output-directory=" . expand('%:r') . "_" . g:latex_outdir
else
let output = ""
end
if g:latexmk_use==1 then
let pdf_command = "latexmk -pdf -halt-on-error -shell-escape " . output . " " . expand('%:r') . ".tex"
else
let pdf_command = "pdflatex -shell-escape " . output . " " . expand('%:r') . ".tex"
end
execute("!" . command)
execute("!" . pdf_command)
endfunction
function! ConvertPandocPdfLatex()
let command = "pandoc " . @% . " -s -o " . expand('%:r') . ".tex"
let output = ""
if g:latex_use_outdir==1 then
let output = "-output-directory=" . expand('%:r') . "_" . g:latex_outdir
else
let output = ""
end
if g:latexmk_use==1 then
let pdf_command = "latexmk -pdf -halt-on-error -shell-escape " . output . " " . expand('%:r') . ".tex"
let pdf_cleanup = "latexmk -c " . output . " " . expand('%:r') . ".tex"
else
let pdf_command = "pdflatex -shell-escape " . output . " " . expand('%:r') . ".tex"
end
if g:use_async==1 then
if len(g:jobs) > 0 then
let index = 0
while index < len(g:jobs)
let item = g:jobs[index]
call jobstop(item)
let index = index + 1
endwhile
end
let current_job = jobstart(command, g:callbacks)
call insert(g:jobs, current_job)
echom 'Running ' . command . ' with Job-Nr. ' . current_job
call jobwait([current_job], 30000)
echom "Conversion from " . @% . " to " . expand('%:r') . ".tex finished"
let current_job = jobstart(pdf_command, g:callbacks_no_out)
call insert(g:jobs, current_job)
echom 'Running ' . pdf_command . ' with Job-Nr. ' . current_job
let result = jobwait([current_job], 120000)
if result[0]==-1 then
echom "Generation of " . expand('%:r') . ".pdf timed out"
elseif result[0]==-2 then
echom "Generation of " . expand('%:r') . ".pdf terminated"
elseif result[0]==-3 then
echom "INVALID JOB-ID: Generation of " . expand('%:r') . ".pdf terminated"
else
echom "Generation of " . expand('%:r') . ".pdf finished"
if g:latexmk_use==1 then
if g:latexmk_clean==1 then
let current_job = jobstart(pdf_cleanup, g:callbacks)
call insert(g:jobs, current_job)
echom 'Running' . pdf_cleanup . ' with Job-Nr. ' . current_job
call jobwait([current_job], 30000)
echom "Cleaned up for " . expand('%:r')
end
end
end
else
execute("!" . command)
echom "Conversion finished"
execute("!" . pdf_command)
echom "Compilation finished"
if g:latexmk_use==1 then
execute("!" . pdf_cleanup)
echom "Cleanup finished"
end
end
endfunction
function! ToggleCompileOnSave()
if g:compile_on_save == 1 then
let g:compile_on_save=0
echom "Compile on save is now turned OFF"
else
let g:compile_on_save=1
echom "Compile on save is now turned ON"
end
endfunction
function! ConvertPandocOnSave(args)
if g:compile_on_save == 1 then
call ConvertPandoc(a:args)
execute "normal \<CR>"
end
endfunction
]])
vim.keymap.set('n', '<leader>pm :call', 'ConvertPandoc("md-to-pdf")<CR><CR>')
vim.keymap.set('n', '<leader>pM :call', 'ConvertPandoc("md-html-to-pdf")<CR><CR>')
vim.keymap.set('n', '<leader>ph :call', 'ConvertPandoc("md-to-html")<CR><CR>')
vim.keymap.set('n', '<leader>pl :call', 'ConvertPandocPdfLatex()<CR><CR>')
vim.keymap.set('n', '<leader>pd :call', 'ConvertPandocPdfLatexDebug()<CR>')
vim.keymap.set('n', '<leader>pp :AsyncStop<CR>:call', 'OpenPdf()<CR>')
vim.keymap.set('n', '<leader>po', ':AsyncStop<CR>:AsyncRun<Space>sumatrapdf<Space>')
vim.keymap.set('n', '<leader>pc :call', 'ToggleCompileOnSave()<CR>')
--vim.cmd('autocmd FileType pandoc autocmd BufWritePost <buffer> call ConvertPandoc(g:pandoc_default) | execute("normal \<CR>")')
vim.cmd('autocmd FileType pandoc silent autocmd BufWritePost <buffer> silent! call ConvertPandocOnSave(g:pandoc_default')
--vim.cmd('autocmd FileType tex silent autocmd BufWritePost <buffer> silent! call ConvertPandoc("latex-to-pdf")')
end
-- ===
-- ===
-- Setup latexmk
-- ===
if vim.g.use_latexmk == true then
vim.cmd([[
function! ConvertPdfLatexDebug()
if g:latexmk_use==1 then
let pdf_command = "latexmk -pdf -halt-on-error -shell-escape " . output . " " . expand('%:r') . ".tex"
else
let pdf_command = "pdflatex -shell-escape " . output . " " . expand('%:r') . ".tex"
end
execute("!" . command)
execute("!" . pdf_command)
endfunction
function! ConvertPdfLatex()
let pdf_command = "latexmk -pdf -halt-on-error -shell-escape " . expand('%:r') . ".tex"
let pdf_cleanup = "latexmk -c " . expand('%:r') . ".tex"
if len(g:jobs) > 0 then
let index = 0
while index < len(g:jobs)
let item = g:jobs[index]
call jobstop(item)
let index = index + 1
endwhile
end
let current_job = jobstart(pdf_command, g:callbacks_no_out)
call insert(g:jobs, current_job)
echom 'Running ' . pdf_command . ' with Job-Nr. ' . current_job
let result = jobwait([current_job], 120000)
if g:latexmk_clean==1 then
let current_job = jobstart(pdf_cleanup, g:callbacks)
call insert(g:jobs, current_job)
echom 'Running' . pdf_cleanup . ' with Job-Nr. ' . current_job
call jobwait([current_job], 30000)
echom "Cleaned up for " . expand('%:r')
end
endfunction
function! CleanLatexDir(full)
if a:full==0 then
let clean="c"
else
let clean="C"
end
let curr_dir = getcwd()
execute("cd " . expand('%:p:h'))
"let pdf_cleanup = "latexmk -" . clean . " " . expand('%:r') . ".tex"
let pdf_cleanup = "latexmk -" . clean
execute("!" . pdf_cleanup)
execute("cd " . curr_dir)
endfunction
]])
--vim.keymap.set('n', '<leader>ll', ':call ConvertPdfLatex()<CR><CR>', { noremap = true })
--vim.keymap.set('n', '<leader>lL', ':call ConvertPdfLatexDebug()<CR><CR>', { noremap = true })
vim.keymap.set('n', '<leader>lc', ':call CleanLatexDir(0)<CR><CR>', { noremap = true })
vim.keymap.set('n', '<leader>lC', ':call CleanLatexDir(1)<CR><CR>', { noremap = true })
--vim.keymap.set('n', '<localleader>ll', ':call ConvertPdfLatex()<CR><CR>', { noremap = true })
--vim.keymap.set('n', '<localleader>lL', ':call ConvertPdfLatexDebug()<CR><CR>', { noremap = true })
--vim.keymap.set('n', '<localleader>lc', ':! latexmk -c<CR><CR>', { noremap = true })
--vim.keymap.set('n', '<localleader>lC', ':! latexmk -C<CR><CR>', { noremap = true })
end
-- ===
-- ===
-- Setup Asciidoctor
-- ===
if vim.g.use_asciidoctor == true then
vim.cmd([[
function! AsciidoctorConvert()
execute("!asciidoctor " . expand('%'))
endfunction
function! AsciidoctorPdfConvert()
execute("!asciidoctor-pdf " . expand('%'))
endfunction
function! AsciidoctorEpubConvert()
execute("!asciidoctor-epub3 " . expand('%'))
endfunction
]])
vim.keymap.set('n', '<leader>aa :call', 'AsciidoctorConvert()<CR>')
vim.keymap.set('n', '<leader>ap :call', 'AsciidoctorPdfConvert()<CR>')
vim.keymap.set('n', '<leader>ae :call', 'AsciidoctorEpubConvert()<CR>')
vim.keymap.set('n', '<leader>ant', 'i[.lightbox, cols="^2,^2", {LIGHTBOX}]<CR>\\|===<CR>\\|===<CR><ESC>kk')
vim.keymap.set('n', '<leader>ani', 'aimage:./images/picture.jpg[picture, {POPUP}]<ESC>')
end
-- ===

259
lua/plugins.lua Normal file
View File

@ -0,0 +1,259 @@
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
-- ===
-- Core
-- ===
if vim.g.use_async == true then
use 'skywind3000/asyncrun.vim'
end
if vim.g.use_sound == true then
use {
'timeyyy/orchestra.nvim.git',
'timeyyy/bubbletrouble.symphony.git',
'timeyyy/clackclack.symphony'
}
end
if vim.g.use_airline == true then
use {
'vim-airline/vim-airline',
'vim-airline/vim-airline-themes'
}
end
if vim.g.use_lualine == true then
use {
'nvim-lualine/lualine.nvim',
-- requires = { 'kyazdani42/nvim-web-devicons', opt = true },
config = function()
require('lualine').setup {
options = {
theme = 'dracula'
}
}
end
}
end
if vim.g.use_comfortable_motion == true then
use 'yuttie/comfortable-motion.vim'
end
if vim.g.use_nerdcommenter == true then
use 'scrooloose/nerdcommenter'
end
-- ===
-- ===
-- Visualizers
-- ===
if vim.g.use_buftabline == true then
use 'ap/vim-buftabline'
end
if vim.g.use_nerdtree == true then
use 'scrooloose/nerdtree'
end
if vim.g.use_bufkill == true then
use 'qpkorr/vim-bufkill'
end
-- ===
-- ===
-- Syntax & Custom indents
-- ===
if vim.g.use_pandoc == true then
use {
'vim-pandoc/vim-pandoc',
'vim-pandoc/vim-pandoc-syntax'
}
end
if vim.g.use_indentguides == true then
use 'thaerkh/vim-indentguides'
end
if vim.g.use_polyglot == true then
use 'sheerun/vim-polyglot'
end
if vim.g.use_vimtex == true then
use 'lervag/vimtex'
end
if vim.g.use_arm_syntax == true then
use 'ARM9/arm-syntax-vim'
end
if vim.g.use_asm_indent == true then
use 'philj56/vim-asm-indent'
end
if vim.g.use_sxhkd == true then
use 'kovetskiy/sxhkd-vim'
end
if vim.g.use_clang_format == true then
use 'rhysd/vim-clang-format'
end
if vim.g.use_fswitch == true then
use 'derekwyatt/vim-fswitch'
end
-- ===
-- ===
-- Git
-- ===
if vim.g.use_fugitive == true then
use 'tpope/vim-fugitive'
end
-- ===
-- ===
-- LSP
-- ===
if vim.g.use_lsp == true then
use {
'williamboman/nvim-lsp-installer',
{
'neovim/nvim-lspconfig',
config = function()
require("nvim-lsp-installer").setup {}
local lspconfig = require("lspconfig")
lspconfig.sumneko_lua.setup {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
},
runtime = {
version = "LuaJIT",
path = vim.split(package.path, ";")
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true
}
}
}
}
}
end
},
}
use 'tami5/lspsaga.nvim'
end
-- ===
-- ===
-- Treesitter
-- ===
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
-- ===
-- Telescope
-- ===
use {
'nvim-telescope/telescope.nvim',
requires = { {'nvim-lua/plenary.nvim'} },
config = function()
require('telescope').setup()
end
}
-- ===
-- ===
-- Gitsigns
-- ===
use {
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup()
end
-- tag = 'release' -- To use the latest release
}
-- ===
-- ===
-- Autocompletion
-- ===
if vim.g.use_autocomplete == 1 then
use 'DustVoice/VimCompletesMe'
elseif vim.g.use_autocomplete == 2 then
if vim.fn['has']('nvim') then
use { 'Shougo/deoplete.nvim', run = ':UpdateRemotePlugins' }
else
use {
'Shougo/deoplete.nvim',
'roxma/nvim-yarp',
'roxma/vim-hug-neovim-rpc'
}
end
elseif vim.g.use_autocomplete == 3 then
use 'ycm-core/YouCompleteMe'
end
if vim.g.use_javacomplete == true then
use 'artur-shaik/vim-javacomplete2'
end
-- ===
-- ===
-- CoC
-- ===
if vim.g.use_coc == true then
use { 'neoclide/coc.nvim', branch = 'release'}
end
-- ===
-- ===
-- Rust
-- ===
if vim.g.use_rust == true then
use 'rust-lang/rust.vim'
end
-- ===
-- ===
-- Special functionality
-- ===
if vim.g.use_python == true then
use 'dhruvasagar/vim-table-mode'
end
if vim.g.use_livedown == true then
use 'shime/vim-livedown'
end
-- ===
-- ===
-- Templating
-- ===
if vim.g.use_templator == true then
use 'DustVoice/templator_vim'
end
-- ===
-- ===
-- Colorscheme
-- ===
use {'dracula/vim', as = 'dracula'}
use {'catppuccin/nvim', as = 'catppuccin'}
if vim.g.use_alt_colorschemes == true then
use 'ajmwagar/vim-deus'
use 'chriskempson/base16-vim'
end
-- ===
end)

39
lua/post_plugins.lua Normal file
View File

@ -0,0 +1,39 @@
local lspconfig = require('lspconfig')
local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'sumneko_lua', 'rust_analyzer' }
for _, lsp in pairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach
}
end

203
lua/settings.lua Normal file
View File

@ -0,0 +1,203 @@
HOME = os.getenv("HOME")
vim.opt.compatible = false
-- ===
-- Platform specific settings. Configure your platform in iniinitlua, in the platform dir.
-- ===
if vim.g.platform == "linux" then
-- vim.cmd('autocmd VimLeave * set guicursor=a:ver35-blinkon0')
-- vim.opt.guicursor = ""
local supported_terminals = {"alacritty", "st-256color", "xterm-256color", "screen", "screen-256color"}
local function is_supported(tbl, str)
for _, element in ipairs(tbl) do
if (element == str) then
return true
end
end
return false
end
if is_supported(supported_terminals, os.getenv("TERM")) and vim.fn['has']("termguicolors") == 1 then
vim.opt.termguicolors = true
else
vim.opt.termguicolors = false
vim.cmd('autocmd ColorScheme dracula hi Visual cterm=reverse')
end
elseif vim.g.platform == "xterm" then
vim.opt.termguicolors = false
vim.opt.guicursor = ""
vim.opt.t_Co = ""
vim.cmd('autocmd ColorScheme dracula hi Visual cterm=reverse')
else
vim.opt.termguicolors = true
end
vim.env.NVIM_TUI_ENABLE_TRUE_COLOR = 1
-- ===
-- ===
-- Choose the mapleaders, in my case the spacebar.
-- ===
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- ===
-- ===
-- Enable mouse support
-- ===
vim.opt.mouse = "a"
-- ===
-- ===
-- Set basic options
-- ===
vim.cmd([[
filetype plugin on
syntax enable
]])
vim.opt.autoindent = true
vim.opt.autoread = true
vim.opt.backspace = { "indent", "eol", "start" }
vim.opt.breakindent = true
vim.opt.breakindentopt = "shift:4"
vim.opt.clipboard = "unnamedplus"
vim.opt.confirm = true
vim.opt.diffopt = { "filler", "vertical" }
vim.opt.expandtab = true
vim.opt.ignorecase = true
vim.opt.incsearch = true
vim.opt.linebreak = true
vim.opt.list = true
vim.opt.listchars = { trail = "·", tab = "\\", extends = "", precedes = "" }
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.scrolloff = 1
vim.opt.shiftwidth = 4
vim.opt.shortmess = "a"
vim.opt.smartcase = true
vim.opt.smartindent = true
vim.opt.softtabstop = 4
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.wrap = true
-- ===
-- ===
-- Set config variables, in order to change options by only modifying these variable values. then
-- Sometimes this can also change the plugins used/needed.
-- ===
local config = {
http_server = "",
jobs = {},
manual_fold_autoload = true,
tex_indent_items = false,
tex_items = "",
use_airline = false,
use_alt_colorschemes = true,
use_arm_syntax = false,
use_asciidoctor = true,
use_asm_indent = true,
use_async = true,
use_autocomplete = 0,
use_bufkill = true,
use_buftabline = true,
use_clang_format = false,
use_coc = false,
use_comfortable_motion = false,
use_cpp = true,
use_font = false,
use_fswitch = true,
use_fugitive = true,
use_indentguides = false,
use_javacomplete = false,
use_latexmk = false,
use_lualine = true,
use_lsp = true,
use_livedown = false,
use_nerdcommenter = true,
use_nerdtree = true,
use_pandoc = false,
use_polyglot = false,
use_python = true,
use_rust = true,
use_sound = false,
use_sxhkd = true,
use_templator = false,
use_utf8 = true,
use_vimtex = true,
ycm_clang = "",
ycm_confirm_extra_conf = false,
ycm_filetype_whitelist = { cpp = 1 },
ycm_java = ""
}
for key, value in pairs(config) do
if not vim.g[key] then
vim.g[key] = value
end
end
-- ===
-- ===
-- Now these settings get applied.
-- ===
if vim.g.use_utf8 == true then
vim.opt.encoding = "utf-8"
end
if vim.g.use_autocomplete == 3 then
vim.g.ycm_clang = " --clang-completer" -- or "--clangd-completer" or ""
vim.g.ycm_java = " --java-completer" -- or ""
end
if vim.g.use_font == true then
vim.opt.showbreak = ""
end
-- ===
-- ===
-- arm-assembly
-- ===
vim.cmd([[
function! SetupArm()
execute('set filetype=arm')
endfunction
au BufNewFile,BufRead *.s,*.S call SetupArm() " arm = armv6/7
]])
-- ===
-- ===
-- When to use 'normal' tabs
-- ===
vim.cmd([[
autocmd FileType make setlocal noexpandtab
autocmd FileType Makefile setlocal noexpandtab
]])
-- ===
-- ===
-- Don't schow relative numbers in insert mode, but show them in normal mode
-- ===
vim.cmd([[
autocmd BufWinEnter,BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufWinLeave,BufLeave,FocusLost,InsertEnter * set norelativenumber
]])
-- ===
-- ===
-- Colorscheme
-- ===
vim.cmd('colorscheme dracula')
-- ===
--vim.cmd("hi LineNr guifg=#B0BEC5")
--vim.cmd("hi CursorLineNr guifg=#64FFDA")

132
lua/utilities.lua Normal file
View File

@ -0,0 +1,132 @@
-- ===
-- Function to delete a 'stuck'
-- swap file for the current buffer
-- ===
vim.cmd([[
function! DeleteFileSwaps()
write
let l:output = ''
redir => l:output
silent exec ':sw'
redir END
let l:current_swap_file = substitute(l:output, '\n', '', '')
let l:base = substitute(l:current_swap_file, '\v\.\w+$', '', '')
let l:swap_files = split(glob(l:base.'\.s*'))
" delete all except the current swap file
for l:swap_file in l:swap_files
if !empty(glob(l:swap_file)) && l:swap_file != l:current_swap_file then
call delete(l:swap_file)
echo "swap file removed: ".l:swap_file
end
endfor
" Reset swap file extension to `.swp`.
set swf! | set swf!
echo "Reset swap file extension for file: ".expand('%')
endfunction
command! DeleteFileSwaps :call DeleteFileSwaps()
]])
-- ===
-- ===
-- Setup F11/S-F11 for fullscreen/maximize toggle
-- ===
vim.cmd([[
function! FullScreenToggle()
if exists('g:neovide') then
let g:neovide_fullscreen = !g:neovide_fullscreen
else
if g:GuiWindowFullScreen==1 then
call GuiWindowFullScreen(0)
else
call GuiWindowFullScreen(1)
end
end
endfunction
function! MaximizedToggle()
if g:GuiWindowMaximized==1 then
call GuiWindowMaximized(0)
else
call GuiWindowMaximized(1)
end
endfunction
]])
if vim.g.neovide then
vim.keymap.set('n', '<F11>', ':call FullScreenToggle()<CR>', { noremap = true, silent = true })
else
vim.keymap.set('n', '<F11>', ':call MaximizedToggle()<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<S-F11>', ':call FullScreenToggle()<CR>', { noremap = true, silent = true })
end
-- ===
-- ===
-- Setup C++ specific stuff then
-- ===
if vim.g.use_cpp == true then
vim.cmd([[
function! CPP_Include_Guard()
let guard_name = input("Please input the guard name:\n")
if guard_name != "" then
execute("normal! mZ")
execute("normal! gg")
if getline(".") =~ "\." then
execute("normal! O")
end
execute("normal! O#ifndef " . guard_name) then
execute("normal! o#define " . guard_name)
execute("normal! G")
if getline(".") =~ "\." then
execute("normal! o")
end
execute("normal! o#end // " . guard_name)
execute("normal! `Z")
end
endfunction
function! CPP_Comment_File()
let file_desc = input("Please input a short file description:\n")
if file_desc != "" then
let class_name = input("Please input a class name or leave empty:\n")
execute("normal! mZ")
execute("normal! O/**")
execute("normal! o")
execute("normal! S @file " . expand("%:t"))
execute("normal! o@author DustVoice")
execute("normal! o")
if class_name != "" then
execute("normal! o@class " . class_name)
execute("normal! o")
end
execute("normal! o" . file_desc)
execute("normal! o*/")
execute("normal! <<")
execute("normal! `Z")
end
endfunction
function! CPP_Comment_Method()
let func_desc = input("Please input a short function description:\n")
if func_desc != "" then
execute("normal! O/**")
execute("normal! o")
execute("normal! S " . func_desc)
execute("normal! o*/")
execute("normal! <<")
execute("normal! k$")
end
endfunction
command! CppIncludeGuard :call CPP_Include_Guard()
command! CppCommentFile :call CPP_Comment_File()
command! CppCommentMethod :call CPP_Comment_Method()
let b:current_syntax = "custom"
syntax keyword cppCustomNamespace juce
syntax keyword cppCustomNamespace PDFHummus
hi def link cppCustomNamespace Constant
]])
end
-- ===

@ -0,0 +1 @@
Subproject commit 4dedd3b08f8c6e3f84afbce0c23b66320cd2a8f2