From 623ef3a48d047b11b1e9b3deecb16c8fb38f4ec5 Mon Sep 17 00:00:00 2001 From: DustVoice Date: Mon, 30 May 2022 22:20:50 +0200 Subject: [PATCH] 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 --- .gitignore | 5 +- init.lua | 8 + init.vim | 1213 --------------------------------- lua/custom/example.lua | 4 + lua/keymaps.lua | 28 + lua/platform/example.lua | 3 + lua/plugin_options.lua | 725 ++++++++++++++++++++ lua/plugins.lua | 259 +++++++ lua/post_plugins.lua | 39 ++ lua/settings.lua | 203 ++++++ lua/utilities.lua | 132 ++++ pack/packer/start/packer.nvim | 1 + 12 files changed, 1406 insertions(+), 1214 deletions(-) create mode 100644 init.lua delete mode 100644 init.vim create mode 100644 lua/custom/example.lua create mode 100644 lua/keymaps.lua create mode 100644 lua/platform/example.lua create mode 100644 lua/plugin_options.lua create mode 100644 lua/plugins.lua create mode 100644 lua/post_plugins.lua create mode 100644 lua/settings.lua create mode 100644 lua/utilities.lua create mode 160000 pack/packer/start/packer.nvim diff --git a/.gitignore b/.gitignore index 425e225..1ceb306 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..1e854c8 --- /dev/null +++ b/init.lua @@ -0,0 +1,8 @@ +require('plugins') +require('post_plugins') +require('platform') +require('custom') +require('settings') +require('plugin_options') +require('utilities') +require('keymaps') diff --git a/init.vim b/init.vim deleted file mode 100644 index d2d0639..0000000 --- a/init.vim +++ /dev/null @@ -1,1213 +0,0 @@ -set nocompatible - -" === -" Platform specific settings. Configure your platform in platform.vim, in this dir. -" === -runtime platform.vim - -if g:platform ==? "linux" - "autocmd VimLeave * set guicursor=a:ver35-blinkon0 - "set guicursor= - let supported_terminals=["alacritty", "st-256color", "xterm-256color", "screen", "screen-256color"] - if index(supported_terminals, $TERM) != -1 && has("termguicolors") - set termguicolors - else - set notermguicolors - - autocmd ColorScheme dracula hi Visual cterm=reverse - endif -elseif g:platform ==? "xterm" - set notermguicolors - set guicursor= - set t_Co= - autocmd ColorScheme dracula hi Visual cterm=reverse -else - set termguicolors -endif -" === - -" === -" Choose the mapleaders, in my case the spacebar. -" === -let mapleader = " " -let maplocalleader = " " -" === - -" === -" Enable mouse support -" === -set mouse=a -" === - -" === -" Set basic options -" === -filetype plugin on - -set autoindent -set autoread -set backspace=indent,eol,start -set breakindent -set breakindentopt=shift:4 -set clipboard=unnamedplus -set confirm -set diffopt=filler,vertical -set expandtab -set ignorecase -set incsearch -set linebreak -set list -set listchars=trail:·,tab:•\ ,extends:⟩,precedes:⟨ -set number -set relativenumber -set scrolloff=1 -set shiftwidth=4 -set shortmess=a -set smartcase -set smartindent -set softtabstop=4 -set splitbelow -set splitright -set wrap - -syntax enable -" === - - -" === -" Set config variables, in order to change options by only modifying these variable values. -" Sometimes this can also change the plugins used/needed. -" === -let g:http_server = '' - -let g:jobs = [] - -let g:manual_fold_autoload = 1 - -let g:tex_indent_items = 0 -let g:tex_items = '' - -let g:use_airline = 1 -let g:use_alt_colorschemes = 1 -let g:use_arm_syntax = 0 -let g:use_asciidoctor = 1 -let g:use_asm_indent = 1 -let g:use_async = 1 -let g:use_autocomplete=1 -let g:use_bufkill = 1 -let g:use_buftabline = 1 -let g:use_clang_format = 0 -let g:use_coc = 0 -let g:use_comfortable_motion = 0 -let g:use_cpp = 1 -let g:use_font = 0 -let g:use_fswitch = 1 -let g:use_fugitive = 1 -let g:use_indentguides = 0 -let g:use_javacomplete = 0 -let g:use_latexmk = 0 -let g:use_livedown = 0 -let g:use_nerdcommenter = 1 -let g:use_nerdtree = 1 -let g:use_pandoc = 0 -let g:use_polyglot = 0 -let g:use_python = 1 -let g:use_rust = 1 -let g:use_sound = 0 -let g:use_sxhkd = 1 -let g:use_templator = 0 -let g:use_utf8 = 1 -let g:use_vimtex = 1 -let g:ycm_clang = '' -let g:ycm_confirm_extra_conf = 0 -let g:ycm_filetype_whitelist = {'cpp': 1} -let g:ycm_java = '' -" === - -" === -" As the previous settings should be seen as 'default' settings, we prvoide a -" way to set custom values for these. -" Here we load them. -" === -runtime custom.vim -" === - -" === -" Now these settings get applied. -" === -if g:use_utf8 == 1 - set encoding=utf-8 -endif - -if g:use_autocomplete == 3 - let g:ycm_clang = ' --clang-completer' " or '--clangd-completer' or '' - let g:ycm_java = ' --java-completer' " or '' -endif - -if g:use_font == 1 - set showbreak=↳ -endif -" === - -" === -" Begin vim-plug section -" === -call plug#begin() -" === - -" === -" Core -" === -if g:use_async == 1 - Plug 'skywind3000/asyncrun.vim' -endif - -if g:use_sound == 1 - Plug 'https://github.com/timeyyy/orchestra.nvim.git' - Plug 'https://github.com/timeyyy/bubbletrouble.symphony.git' - Plug 'https://github.com/timeyyy/clackclack.symphony' -endif - -if g:use_airline == 1 - Plug 'vim-airline/vim-airline' - Plug 'vim-airline/vim-airline-themes' -endif - -if g:use_comfortable_motion == 1 - Plug 'yuttie/comfortable-motion.vim' -endif - -if g:use_nerdcommenter == 1 - Plug 'scrooloose/nerdcommenter' -endif -" === - -" === -" Visualizers -" === -if g:use_buftabline == 1 - Plug 'ap/vim-buftabline' -endif -if g:use_nerdtree == 1 - Plug 'scrooloose/nerdtree' -endif -if g:use_bufkill == 1 - Plug 'qpkorr/vim-bufkill' -endif -" === - -" === -" Syntax & Custom indents -" === -if g:use_pandoc == 1 - Plug 'vim-pandoc/vim-pandoc' - Plug 'vim-pandoc/vim-pandoc-syntax' -endif - -if g:use_indentguides == 1 - Plug 'thaerkh/vim-indentguides' -endif - -if g:use_polyglot == 1 - Plug 'sheerun/vim-polyglot' -endif - -if g:use_vimtex == 1 - Plug 'lervag/vimtex' -endif - -if g:use_arm_syntax == 1 - Plug 'ARM9/arm-syntax-vim' -endif - -if g:use_asm_indent == 1 - Plug 'philj56/vim-asm-indent' -endif - -if g:use_sxhkd == 1 - Plug 'kovetskiy/sxhkd-vim' -endif - -if g:use_clang_format==1 - Plug 'rhysd/vim-clang-format' -endif - -if g:use_fswitch == 1 - Plug 'derekwyatt/vim-fswitch' -endif -" === - -" === -" Git -" === -if g:use_fugitive == 1 - Plug 'tpope/vim-fugitive' -endif -" === - -" === -" Autocompletion -" === -if g:use_autocomplete == 1 - Plug 'DustVoice/VimCompletesMe' -elseif g:use_autocomplete == 2 - if has('nvim') - Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } - else - Plug 'Shougo/deoplete.nvim' - Plug 'roxma/nvim-yarp' - Plug 'roxma/vim-hug-neovim-rpc' - endif -elseif g:use_autocomplete == 3 - Plug 'ycm-core/YouCompleteMe' -endif - -if g:use_javacomplete == 1 - Plug 'artur-shaik/vim-javacomplete2' -endif -" === - -" === -" CoC -" === -if g:use_coc == 1 - Plug 'neoclide/coc.nvim', {'branch': 'release'} -endif -" === - -" === -" Rust -" === -if g:use_rust == 1 - Plug 'rust-lang/rust.vim' -endif -" === - -" === -" Special functionality -" === -if g:use_python == 1 - Plug 'dhruvasagar/vim-table-mode' -endif - -if g:use_livedown == 1 - Plug 'shime/vim-livedown' -endif -" === - -" === -" Templating -" === -if g:use_templator == 1 - Plug 'DustVoice/templator_vim' -endif -" === - -" === -" Colorscheme -" === -Plug 'dracula/vim',{'as':'dracula'} -if g:use_alt_colorschemes == 1 - Plug 'ajmwagar/vim-deus' - Plug 'chriskempson/base16-vim' -endif -" === - -" === -" End vim-plug section -" === -call plug#end() -" === - -" === -" clang-format -" === -if g:use_clang_format == 1 - let g:clang_format#detect_style_file = 1 - let g:clang_format#enable_fallback_style = 1 - - let g:clang_format#style = "Microsoft" - let 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" } - - let g:clang_format#auto_format = 1 - let g:clang_format#auto_format_on_insert_leave = 0 - - autocmd FileType c,cpp,objc nnoremap cf :ClangFormat - autocmd FileType c,cpp,objc vnoremap cf :ClangFormat - - nmap ct :ClangFormatAutoToggle -endif -" === - -" === -" arm-assembly -" === -function! SetupArm() - execute('set filetype=arm') -endfunction - -au BufNewFile,BufRead *.s,*.S call SetupArm() " arm = armv6/7 -" === - -" === -" Indentguides config -" === -if g:use_indentguides - let g:indentguides_spacechar = '•' - let g:indentguides_tabchar = '|' - let g:indentguides_firstlevel = 1 -endif -" === - -" === -" When to use 'normal' tabs -" === -autocmd FileType make setlocal noexpandtab -autocmd FileType Makefile setlocal noexpandtab -" === - -" === -" Colorscheme -" === -colorscheme dracula -" === - -" === -" Function to delete a 'stuck' -" swap file for the current buffer -" === -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 - call delete(l:swap_file) - echo "swap file removed: ".l:swap_file - endif - endfor - " Reset swap file extension to `.swp`. - set swf! | set swf! - echo "Reset swap file extension for file: ".expand('%') -endfunction -command! DeleteFileSwaps :call DeleteFileSwaps() -" === - -" === -" Comfortable Motion setup -" === -if g:use_comfortable_motion == 1 - let g:comfortable_motion_no_default_key_mappings = 1 - let g:comfortable_motion_impulse_multiplier = 1 " Feel free to increase/decrease this value. - nnoremap :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 1) - nnoremap :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -1) - nnoremap :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 2) - nnoremap :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -2) -endif -" === - -" === -" Setup F11/S-F11 for fullscreen/maximize toggle -" === -function! FullScreenToggle() - if exists('g:neovide') - let g:neovide_fullscreen = !g:neovide_fullscreen - else - if g:GuiWindowFullScreen==1 - call GuiWindowFullScreen(0) - else - call GuiWindowFullScreen(1) - endif - endif -endfunction - -function! MaximizedToggle() - if g:GuiWindowMaximized==1 - call GuiWindowMaximized(0) - else - call GuiWindowMaximized(1) - endif -endfunction - -if exists('g:neovide') - nnoremap :call FullScreenToggle() -else - nnoremap :call MaximizedToggle() - nnoremap :call FullScreenToggle() -endif -" === - -let $NVIM_TUI_ENABLE_TRUE_COLOR=1 - -" === -" Disable polyglot for latex files -" === -if g:use_polyglot == 1 - let g:vim_markdown_conceal = 0 -endif -" === - -" === -" Setup vimtex -" === -if g:use_vimtex == 1 - let g:polyglot_disabled = ['latex', 'tex'] - - let g:tex_flavor='latex' - "let g:vimtex_syntax_packages = {'hyperref':{'load':2}, 'listings':{'load':2}, 'luacode':{'load':2}, 'minted':{'load':2}} - let g:vimtex_format_enabled = 1 - let g:vimtex_indent_enabled = 1 - - "let g:vimtex_indent_ignored_envs = ['document'] - "let g:vimtex_syntax_minted = [{'lang':'text'}, {'lang':'console'}] - - let 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 - - let g:vimtex_view_enabled = 0 - let g:vimtex_view_general_viewer = '' - - "if g:platform ==? "windows" || g:platform ==? "windows_portable" - "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" - "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 = '' - "endif - - "let g:vimtex_fold_enabled=1 - - au BufNewFile,BufRead *.cls call execute('set filetype=tex') -" === -endif -" === - -" === -" Setup javacomplete -" === -if g:use_javacomplete==1 - autocmd FileType java setlocal omnifunc=javacomplete#Complete -endif -" === - -" === -" Setup deoplete -" === -if g:use_autocomplete==2 - let g:deoplete#enable_at_startup = 1 -endif -" === - -" === -" Setup YouCompleteMe -" === -if g:use_autocomplete == 3 - nnoremap ygg :YcmCompleter GoToImprecise - nnoremap yg :YcmCompleter GoTo - - nnoremap ytt :YcmCompleter GetTypeImprecise - nnoremap yt :YcmCompleter GetType - - nnoremap ydd :YcmCompleter GetDocImprecise - nnoremap yd :YcmCompleter GetDoc - - nnoremap yf :YcmCompleter FixIt - - nnoremap yq :YcmDiags - - nnoremap yy :YcmCompleter - - nnoremap yr :YcmRestartServer -endif -" === - -" === -" Setup CoC -" === -if g:use_coc == 1 - set updatetime=300 - - set shortmess+=c - - set signcolumn=yes - - inoremap coc#refresh() - - nmap [g (coc-diagnostic-prev) - nmap ]g (coc-diagnostic-next) - - nmap gd (coc-definition) - nmap gy (coc-type-definition) - nmap gi (coc-implementation) - nmap gr (coc-references) - - nnoremap K :call show_documentation() - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - elseif (coc#rpc#ready()) - call CocActionAsync('doHover') - else - execute '!' . &keywordprg . " " . expand('') - endif - endfunction - - autocmd CursorHold * silent call CocActionAsync('highlight') - - nmap rn (coc-rename) - - xmap f (coc-format-selected) - nmap f (coc-format-selected) - - nmap ac (coc-codeaction) - nmap qf (coc-fix-current) - - if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - endif - - command! -nargs=0 Format :call CocAction('format') - command! -nargs=? Fold :call CocAction('fold', ) - command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - - nnoremap y :CocList -A --normal yank - - let 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'] -endif -" === - -" === -" Setup fswitch -" === -if g:use_fswitch == 1 - nnoremap s :FSHere -endif -" === - -" === -" Setup python -" === -if g:use_python == 1 - let g:table_mode_corner_corner='+' - let g:table_mode_header_fillchar='=' -endif -" === - -" === -" Setup airline -" === -if g:use_airline == 1 - let g:airline_powerline_fonts = 1 - - if !exists('g:airline_symbols') - let g:airline_symbols = {} - if g:use_font == 0 - let g:airline_left_sep = '' - let g:airline_right_sep = '' - let g:airline_symbols.linenr = '␊' - let g:airline_symbols.linenr = '␤' - let g:airline_symbols.linenr = '¶' - let g:airline_symbols.branch = '⎇' - let g:airline_symbols.paste = 'ρ' - let g:airline_symbols.paste = 'Þ' - let g:airline_symbols.paste = '∥' - let g:airline_symbols.whitespace = 'Ξ' - endif - endif - - " === - " unicode symbols - " === - " let g:airline_left_sep = '»' - " let g:airline_left_sep = '▶' - " let g:airline_right_sep = '«' - " let g:airline_right_sep = '◀' - " let g:airline_symbols.linenr = '␊' - " let g:airline_symbols.linenr = '␤' - " let g:airline_symbols.linenr = '¶' - " let g:airline_symbols.branch = '⎇' - " let g:airline_symbols.paste = 'ρ' - " let g:airline_symbols.paste = 'Þ' - " let g:airline_symbols.paste = '∥' - " let g:airline_symbols.whitespace = 'Ξ' - " === - - " === - " airline symbols - " === - " let g:airline_left_sep = '' - " let g:airline_left_alt_sep = '' - " let g:airline_right_sep = '' - " let g:airline_right_alt_sep = '' - " let g:airline_symbols.branch = '' - " let g:airline_symbols.readonly = '' - " let g:airline_symbols.linenr = '' - " === - - let g:airline_theme = "dracula" -endif -" === - -" === -" Setup sound -" === -if g:use_sound==1 - call orchestra#prelude() - - call orchestra#set_tune('bubbletrouble') -endif -" === - -" === -" Setup livedown -" === -if g:use_livedown == 1 - let g:livedown_autorun = 0 - let g:livedown_open = 1 - let g:livedown_port = 1337 - let g:livedown_browser = "firefox -P livedown" - let g:confirm_new_file = 1 - let g:wiki_history = {} - - nmap m :LivedownToggle -endif -" === - -" === -" Setup Nerdtree -" === -if g:use_nerdtree == 1 - map n :NERDTreeToggle -endif -" === - -" === -" Setup pandoc -" === -if g:use_pandoc == 1 - let g:pandoc#syntax#conceal#use = 0 - let g:pandoc#formatting#mode="sa" - let g:pandoc#formatting#smart_autoformat_on_cursormoved=1 - - let g:data = [] - function! g:JobHandler(job_id, data, event) - if a:event == 'stdout' || a:event == 'stderr' - 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 - - let g:callbacks = { - \ 'on_stdout': function('g:JobHandler'), - \ 'on_stderr': function('g:JobHandler'), - \ 'on_exit': function('g:JobHandler') - \ } - - let 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 - - function! OpenPdf() - if g:use_async==1 - let pdf_path = "" - - if g:latex_use_outdir==1 - let pdf_path = expand('%:r') . "_" . g:latex_outdir . "/" . expand('%:t:r') . ".pdf" - else - let pdf_path = expand('%:r') . ".pdf" - endif - - 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") - endif - endfunction - - function! ConvertPandoc(attr) - let command = "" - if a:attr == "md-to-pdf" - let command = "pandoc -s " . @% . " --from=markdown+escaped_line_breaks -o " . expand('%:r') . ".pdf" - elseif a:attr == "md-html-to-pdf" - 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" - let command = "pandoc " . @% . " -s --katex --css=file:///D:/Pandoc/katex_style.css -o " . expand('%:r') . ".html" - elseif a:attr == "latex-to-pdf" - let command = "pandoc " . @% . " -s -o " . expand('%:r') . ".pdf" - endif - - " if g:use_async==1 - " 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 - " 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 - let index = 0 - while index < len(g:jobs) - let item = g:jobs[index] - call jobstop(item) - let index = index + 1 - endwhile - endif - 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" - endif - " endif - - if g:open_pdf==1 - call OpenPdf() normal - endif - 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 - let output = "-output-directory=" . expand('%:r') . "_" . g:latex_outdir - else - let output = "" - endif - - if g:latexmk_use==1 - 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" - endif - - execute("!" . command) - execute("!" . pdf_command) - endfunction - - function! ConvertPandocPdfLatex() - let command = "pandoc " . @% . " -s -o " . expand('%:r') . ".tex" - - let output = "" - if g:latex_use_outdir==1 - let output = "-output-directory=" . expand('%:r') . "_" . g:latex_outdir - else - let output = "" - endif - - if g:latexmk_use==1 - 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" - endif - - if g:use_async==1 - if len(g:jobs) > 0 - let index = 0 - while index < len(g:jobs) - let item = g:jobs[index] - call jobstop(item) - let index = index + 1 - endwhile - endif - - 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 - echom "Generation of " . expand('%:r') . ".pdf timed out" - elseif result[0]==-2 - echom "Generation of " . expand('%:r') . ".pdf terminated" - elseif result[0]==-3 - echom "INVALID JOB-ID: Generation of " . expand('%:r') . ".pdf terminated" - else - echom "Generation of " . expand('%:r') . ".pdf finished" - - if g:latexmk_use==1 - if g:latexmk_clean==1 - 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') - endif - endif - endif - else - execute("!" . command) - echom "Conversion finished" - execute("!" . pdf_command) - echom "Compilation finished" - - if g:latexmk_use==1 - execute("!" . pdf_cleanup) - echom "Cleanup finished" - endif - endif - endfunction - - nmap pm :call ConvertPandoc("md-to-pdf") - nmap pM :call ConvertPandoc("md-html-to-pdf") - nmap ph :call ConvertPandoc("md-to-html") - nmap pl :call ConvertPandocPdfLatex() - nmap pd :call ConvertPandocPdfLatexDebug() - nmap pp :AsyncStop:call OpenPdf() - nmap po :AsyncStop:AsyncRunsumatrapdf - - function! ToggleCompileOnSave() - if g:compile_on_save == 1 - 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" - endif - endfunction - - nmap pc :call ToggleCompileOnSave() - - function! ConvertPandocOnSave(args) - if g:compile_on_save == 1 - call ConvertPandoc(a:args) - execute "normal \" - endif - endfunction - - "autocmd FileType pandoc autocmd BufWritePost call ConvertPandoc(g:pandoc_default) | execute("normal \") - autocmd FileType pandoc silent autocmd BufWritePost silent! call ConvertPandocOnSave(g:pandoc_default) - " autocmd FileType tex silent autocmd BufWritePost silent! call ConvertPandoc("latex-to-pdf") -endif -" === - - -" === -" Setup latexmk -" === -if g:use_latexmk == 1 - function! ConvertPdfLatexDebug() - if g:latexmk_use==1 - 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" - endif - - 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 - let index = 0 - while index < len(g:jobs) - let item = g:jobs[index] - call jobstop(item) - let index = index + 1 - endwhile - endif - - 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 - 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') - endif - endfunction - - function! CleanLatexDir(full) - if a:full==0 - let clean="c" - else - let clean="C" - endif - - 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 - - "nnoremap ll :call ConvertPdfLatex() - "nnoremap lL :call ConvertPdfLatexDebug() - nnoremap lc :call CleanLatexDir(0) - nnoremap lC :call CleanLatexDir(1) - "nnoremap ll :call ConvertPdfLatex() - "nnoremap lL :call ConvertPdfLatexDebug() - "nnoremap lc :! latexmk -c - "nnoremap lC :! latexmk -C -endif -" === - -" === -" Setup Asciidoctor -" === -if g:use_asciidoctor == 1 - function! AsciidoctorConvert() - execute("!asciidoctor " . expand('%')) - endfunction - function! AsciidoctorPdfConvert() - execute("!asciidoctor-pdf " . expand('%')) - endfunction - function! AsciidoctorEpubConvert() - execute("!asciidoctor-epub3 " . expand('%')) - endfunction - - nmap aa :call AsciidoctorConvert() - nmap ap :call AsciidoctorPdfConvert() - nmap ae :call AsciidoctorEpubConvert() - - nmap ant i[.lightbox, cols="^2,^2", {LIGHTBOX}]\|===\|===kk - nmap ani aimage:./images/picture.jpg[picture, {POPUP}] -endif -" === - -" === -" Don't schow relative numbers in insert mode, but show them in normal mode -" === -autocmd BufWinEnter,BufEnter,FocusGained,InsertLeave * set relativenumber -autocmd BufWinLeave,BufLeave,FocusLost,InsertEnter * set norelativenumber -" === - -"hi LineNr guifg=#B0BEC5 -"hi CursorLineNr guifg=#64FFDA - -" === -" General maps (at the bottom to overwrite everything) -" === -nnoremap cd :cd %:p:h -nnoremap lcd :lcd %:p:h - -tnoremap - -nnoremap + + -nnoremap - - -nnoremap < < -nnoremap > > -nnoremap _ _ -nnoremap -nnoremap = = -nnoremap T T - -nmap h :noh - -nmap . :bnext -nmap , :bprev -" === - -" === -" Setup C++ specific stuff -" === -if g:use_cpp == 1 - function! CPP_Include_Guard() - let guard_name = input("Please input the guard name:\n") - if guard_name != "" - execute("normal! mZ") - execute("normal! gg") - if getline(".") =~ "\." - execute("normal! O") - endif - execute("normal! O#ifndef " . guard_name) - execute("normal! o#define " . guard_name) - execute("normal! G") - if getline(".") =~ "\." - execute("normal! o") - endif - execute("normal! o#endif // " . guard_name) - execute("normal! `Z") - endif - endfunction - - function! CPP_Comment_File() - let file_desc = input("Please input a short file description:\n") - if file_desc != "" - 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 != "" - execute("normal! o@class " . class_name) - execute("normal! o") - endif - execute("normal! o" . file_desc) - execute("normal! o*/") - execute("normal! <<") - execute("normal! `Z") - endif - endfunction - - function! CPP_Comment_Method() - let func_desc = input("Please input a short function description:\n") - if func_desc != "" - execute("normal! O/**") - execute("normal! o") - execute("normal! S " . func_desc) - execute("normal! o*/") - execute("normal! <<") - execute("normal! k$") - endif - 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 -endif -" === - -" === -" Background -" === -nmap bg :let &background = ( &background == "dark"? "light" : "dark" ) -" === diff --git a/lua/custom/example.lua b/lua/custom/example.lua new file mode 100644 index 0000000..0080d55 --- /dev/null +++ b/lua/custom/example.lua @@ -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 diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..2405d22 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,28 @@ +-- === +-- General maps +-- === +vim.keymap.set('n', 'cd', ':cd %:p:h', { noremap = true, silent = true }) +vim.keymap.set('n', 'lcd', ':lcd %:p:h', { noremap = true, silent = true }) + +vim.keymap.set('t', '', '', { noremap = true }) + +vim.keymap.set('n', '+', '+', { noremap = true }) +vim.keymap.set('n', '-', '-', { noremap = true }) +vim.keymap.set('n', '<', '<', { noremap = true }) +vim.keymap.set('n', '>', '>', { noremap = true }) +vim.keymap.set('n', '_', '_', { noremap = true }) +vim.keymap.set('n', '', '', { noremap = true }) +vim.keymap.set('n', '=', '=', { noremap = true }) +vim.keymap.set('n', 'T', 'T', { noremap = true }) + +vim.keymap.set('n', 'h', ':noh') + +vim.keymap.set('n', '.', ':bnext') +vim.keymap.set('n', ',', ':bprev') +-- === + +-- === +-- Background +-- === +vim.keymap.set('n', 'bg', ':let &background = ( &background == "dark"? "light" : "dark" )') +-- === diff --git a/lua/platform/example.lua b/lua/platform/example.lua new file mode 100644 index 0000000..e2c2410 --- /dev/null +++ b/lua/platform/example.lua @@ -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" diff --git a/lua/plugin_options.lua b/lua/plugin_options.lua new file mode 100644 index 0000000..7c9fc36 --- /dev/null +++ b/lua/plugin_options.lua @@ -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 cf :ClangFormat + autocmd FileType c,cpp,objc vnoremap cf :ClangFormat + ]]) + + vim.keymap.set('n', 'ct', ':ClangFormatAutoToggle') +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', '', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 1)', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -1)', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 2)', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -2)', { 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', 'ygg', ':YcmCompleter GoToImprecise', { noremap = true }) + vim.keymap.set('n', 'yg', ':YcmCompleter GoTo', { noremap = true }) + + vim.keymap.set('n', 'ytt', ':YcmCompleter GetTypeImprecise', { noremap = true }) + vim.keymap.set('n', 'yt', ':YcmCompleter GetType', { noremap = true }) + + vim.keymap.set('n', 'ydd', ':YcmCompleter GetDocImprecise', { noremap = true }) + vim.keymap.set('n', 'yd', ':YcmCompleter GetDoc', { noremap = true }) + + vim.keymap.set('n', 'yf', ':YcmCompleter FixIt', { noremap = true }) + + vim.keymap.set('n', 'yq', ':YcmDiags', { noremap = true }) + + vim.keymap.set('n', 'yy', ':YcmCompleter', { noremap = true }) + + vim.keymap.set('n', 'yr', ':YcmRestartServer', { 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', '', 'coc#refresh()', { noremap = true }) + + vim.keymap.set('n', '[g', '(coc-diagnostic-prev)', { silent = true }) + vim.keymap.set('n', ']g', '(coc-diagnostic-next)', { silent = true }) + + vim.keymap.set('n', 'gd', '(coc-definition)', { silent = true }) + vim.keymap.set('n', 'gy', '(coc-type-definition)', { silent = true }) + vim.keymap.set('n', 'gi', '(coc-implementation)', { silent = true }) + vim.keymap.set('n', 'gr', '(coc-references)', { silent = true }) + + vim.keymap.set('n', ' K', ':call show_documentation()', { noremap = true }) + + vim.cmd([[ + function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) then + execute 'h '.expand('') + elseif (coc#rpc#ready()) then + call CocActionAsync('doHover') + else + execute '!' . &keywordprg . " " . expand('') + end + endfunction + + autocmd CursorHold * silent call CocActionAsync('highlight') + ]]) + + vim.keymap.set('n', 'rn', '(coc-rename)') + + vim.keymap.set('x', 'f ', '(coc-format-selected)') + vim.keymap.set('n', 'f ', '(coc-format-selected)') + + vim.keymap.set('n', 'ac ', '(coc-codeaction)') + vim.keymap.set('n', 'qf ', '(coc-fix-current)') + + vim.cmd([[ + if has('nvim-0.4.0') || has('patch-8.2.0750') then + nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + end + + command! -nargs=0 Format :call CocAction('format') + command! -nargs=? Fold :call CocAction('fold', ) + command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + ]]) + + vim.keymap.set('n', 'y', ':CocList -A --normal yank', { 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', 's', ':FSHere', { 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', 'm', ':LivedownToggle') +end +-- === + +-- === +-- Setup Nerdtree +-- === +if vim.g.use_nerdtree == true then + vim.keymap.set({ 'n', 'v', 'o' }, 'map n', ':NERDTreeToggle') +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 + 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 \" + end + endfunction + ]]) + + vim.keymap.set('n', 'pm :call', 'ConvertPandoc("md-to-pdf")') + vim.keymap.set('n', 'pM :call', 'ConvertPandoc("md-html-to-pdf")') + vim.keymap.set('n', 'ph :call', 'ConvertPandoc("md-to-html")') + vim.keymap.set('n', 'pl :call', 'ConvertPandocPdfLatex()') + vim.keymap.set('n', 'pd :call', 'ConvertPandocPdfLatexDebug()') + vim.keymap.set('n', 'pp :AsyncStop:call', 'OpenPdf()') + vim.keymap.set('n', 'po', ':AsyncStop:AsyncRunsumatrapdf') + + vim.keymap.set('n', 'pc :call', 'ToggleCompileOnSave()') + + --vim.cmd('autocmd FileType pandoc autocmd BufWritePost call ConvertPandoc(g:pandoc_default) | execute("normal \")') + vim.cmd('autocmd FileType pandoc silent autocmd BufWritePost silent! call ConvertPandocOnSave(g:pandoc_default') + --vim.cmd('autocmd FileType tex silent autocmd BufWritePost 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', 'll', ':call ConvertPdfLatex()', { noremap = true }) + --vim.keymap.set('n', 'lL', ':call ConvertPdfLatexDebug()', { noremap = true }) + vim.keymap.set('n', 'lc', ':call CleanLatexDir(0)', { noremap = true }) + vim.keymap.set('n', 'lC', ':call CleanLatexDir(1)', { noremap = true }) + --vim.keymap.set('n', 'll', ':call ConvertPdfLatex()', { noremap = true }) + --vim.keymap.set('n', 'lL', ':call ConvertPdfLatexDebug()', { noremap = true }) + --vim.keymap.set('n', 'lc', ':! latexmk -c', { noremap = true }) + --vim.keymap.set('n', 'lC', ':! latexmk -C', { 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', 'aa :call', 'AsciidoctorConvert()') + vim.keymap.set('n', 'ap :call', 'AsciidoctorPdfConvert()') + vim.keymap.set('n', 'ae :call', 'AsciidoctorEpubConvert()') + + vim.keymap.set('n', 'ant', 'i[.lightbox, cols="^2,^2", {LIGHTBOX}]\\|===\\|===kk') + vim.keymap.set('n', 'ani', 'aimage:./images/picture.jpg[picture, {POPUP}]') +end +-- === diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..c982c3a --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,259 @@ +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | 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) diff --git a/lua/post_plugins.lua b/lua/post_plugins.lua new file mode 100644 index 0000000..d7a3615 --- /dev/null +++ b/lua/post_plugins.lua @@ -0,0 +1,39 @@ +local lspconfig = require('lspconfig') + +local opts = { noremap = true, silent = true } +vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) +vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) +vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) +vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', 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 + 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', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', 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 diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 0000000..a76e4fd --- /dev/null +++ b/lua/settings.lua @@ -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") diff --git a/lua/utilities.lua b/lua/utilities.lua new file mode 100644 index 0000000..fc7cb4f --- /dev/null +++ b/lua/utilities.lua @@ -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', '', ':call FullScreenToggle()', { noremap = true, silent = true }) +else + vim.keymap.set('n', '', ':call MaximizedToggle()', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':call FullScreenToggle()', { 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 +-- === diff --git a/pack/packer/start/packer.nvim b/pack/packer/start/packer.nvim new file mode 160000 index 0000000..4dedd3b --- /dev/null +++ b/pack/packer/start/packer.nvim @@ -0,0 +1 @@ +Subproject commit 4dedd3b08f8c6e3f84afbce0c23b66320cd2a8f2