Closed al3xandru closed 4 years ago
Hi @al3xandru,
Thank you for reporting! Does nothing work, or only some mappings? It's a good thing you checked for g:mkdx#settings
, this means that at least the mappings and settings do get loaded.
It could depend on your plugin manager, which one do you use? If you've manually installed it I'd need more info as to which files you copied.
In any case, mkdx does not step on user-defined mappings, so if only some functionality seems to "not work" there is probably a mapping defined by some other plugin which will prevent mkdx from actually mapping it, these can be checked with :verbose map <prefix>t
where you replace <prefix>
with the actual prefix key you use.
Perhaps, loading mkdx as the first plugin will allow it to map more keys, this could be an easy way to check if more functionality gets enabled then. (this is never true since mappings are loaded after entering markdown buffers, thus always last-in-slot)
I'd love to hear the results on any of the above, thanks for trying mkdx and hopefully the above can solve / narrow down the issue :)
Hi again @al3xandru, I made an edit to my previous comment since the section about loading mkdx first will not do anything actually, my bad there!
Thanks for the follow up. As I don't really know how to start tracking this I will take it step by step.
echo g:mkdx#settings.enter.enable
-> 1echo g:mdx#settings.tokens.enter
-> ['-', '*', '>'] Given the above, my expectation was that while in a list item (or inside a blockquote), pressing enter would automatically add the prefix character to the next line.
:call mkdx#ToggleList()
, the function is invoked and text updated.This makes me thing that while the plugin is active, bindings are not working. Any ideas what I should check next?
Next experiment. I have added the following settings in my .vimrc
:
let g:mkdx#settings.map.prefix = '<localleader>'
let g:mkdx#settings.tokens.italic = '_'
After reloading, restarting:
echo g:mkdx#settings.map.prefix
<leader>
echo g:mkdx#settings.tokens.italic
*
When starting vim from Terminal:
Error detected while processing ~/.vimrc:
line 1023:
E121: Undefined variable: g:mkdx#settings
line 1025:
E121: Undefined variable: g:mkdx#settings
Press ENTER or type command to continue
I'm using vim-plug as a plugin manager.
Hi @al3xandru,
that is strange indeed, it's the first time I'm hearing of the issue that the settings are undefined :thinking:. Which kind of "Vim" are you using? Also, which version of Vim/Nvim/Gvim are you using? Where did you put the settings (did you place them below call plug#end()
)?
Also, can you try other mappings? Like try to mark something as bold using <leader>b
? Please try more than one different mapping to see if some things do work (we already know enter doesn't, what about other functionality?), I've documented all of them here.
Can you post results of some :verbose map
commands you ran while editing a markdown file?
Could you try :verbose imap <cr>
for example? This should show you something like:
This shows that <Plug>(mkdx-enter)
is indeed mapped to <cr>
in my case.
Seeing as you mentioned that o
also doesn't work, could you post :verbose nmap o
too?:
I don't think it is an issue with mkdx, since it's a pretty unique issue and I've already handled quite a few issues before, it could be that you're using an older vim/nvim/gvim which won't work, in which case I'd need to update docs to inform users.
It is also likely that these mappings are already being overridden by some other plugin, can you test mkdx in isolation, e.g disable all other plugins except mkdx and see if that makes a difference?
Keep me posted whenever you have had time to investigate, looking forward to a response. I must mention though that there isn't much else I can do but guess. If you could share your vimrc file I can try it out for myself and see if I can get things to work that way, this may be faster than trying to ask for specific details and I'm willing to give it a shot :)
I didn't know about the :verbose map
command. Thank you.
Both are returning the mkdx binding. The mystery continues.
My .vimrc
: https://github.com/al3xandru/dotfiles/blob/vimplug/.vimrc
I don't know of any ways to try a plugin in isolation. Can you point me towards anything?
You asked above about versions:
vim (built from source):
:version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 8 2020 19:30:16)
macOS version
Included patches: 1-717
Compiled by alex@202005081928/7d131b071
Huge version without GUI. Features included (+) or not (-):
+acl +cmdline_info -farsi +langmap +mouse_sgr +profile +tag_binary +virtualedit
+arabic +comments +file_in_path +libcall -mouse_sysmouse +python/dyn -tag_old_static +visual
+autocmd +conceal +find_in_path +linebreak +mouse_urxvt +python3/dyn -tag_any_white +visualextra
+autochdir +cryptv +float +lispindent +mouse_xterm +quickfix -tcl +viminfo
-autoservername +cscope +folding +listcmds +multi_byte +reltime +termguicolors +vreplace
-balloon_eval +cursorbind -footer +localmap +multi_lang +rightleft +terminal +wildignore
+balloon_eval_term +cursorshape +fork() +lua/dyn -mzscheme -ruby +terminfo +wildmenu
-browse +dialog_con -gettext +menu +netbeans_intg +scrollbind +termresponse +windows
++builtin_terms +diff -hangul_input +mksession +num64 +signs +textobjects +writebackup
+byte_offset +digraphs +iconv +modify_fname +packages +smartindent +textprop -X11
+channel -dnd +insert_expand +mouse +path_extra -sound +timers -xfontset
+cindent -ebcdic +ipv6 -mouseshape +perl/dyn +spell +title -xim
-clientserver +emacs_tags +job +mouse_dec +persistent_undo +startuptime -toolbar -xpm
+clipboard +eval +jumplist -mouse_gpm +popupwin +statusline +user_commands -xsmp
+cmdline_compl +ex_extra +keymap -mouse_jsbterm +postscript -sun_workshop +vartabs -xterm_clipboard
+cmdline_hist +extra_search +lambda +mouse_netterm +printer +syntax +vertsplit -xterm_save
Macvim (latest):
:version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 18 2020 12:38:50)
macOS version
Included patches: 1-539
Compiled by alex@202004181237@5de428cde
Huge version with MacVim GUI. Features included (+) or not (-):
+acl +dnd +listcmds +popupwin +termresponse
+arabic -ebcdic +localmap +postscript +textobjects
+autocmd +emacs_tags +lua/dyn +printer +textprop
+autochdir +eval +menu +profile +timers
-autoservername +ex_extra +mksession +python/dyn +title
+balloon_eval +extra_search +modify_fname +python3/dyn +toolbar
+balloon_eval_term -farsi +mouse +quickfix +transparency
+browse +file_in_path +mouseshape +reltime +user_commands
++builtin_terms +find_in_path +mouse_dec +rightleft +vartabs
+byte_offset +float -mouse_gpm -ruby +vertsplit
+channel +folding -mouse_jsbterm +scrollbind +virtualedit
+cindent -footer +mouse_netterm +signs +visual
+clientserver +fork() +mouse_sgr +smartindent +visualextra
+clipboard +fullscreen -mouse_sysmouse -sound +viminfo
+cmdline_compl -gettext +mouse_urxvt +spell +vreplace
+cmdline_hist -hangul_input +mouse_xterm +startuptime +wildignore
+cmdline_info +iconv +multi_byte +statusline +wildmenu
+comments +insert_expand +multi_lang -sun_workshop +windows
+conceal +job -mzscheme +syntax +writebackup
+cryptv +jumplist +netbeans_intg +tag_binary -X11
+cscope +keymap +num64 -tag_old_static -xfontset
+cursorbind +lambda +odbeditor -tag_any_white +xim
+cursorshape +langmap +packages -tcl -xpm
+dialog_con_gui +libcall +path_extra +termguicolors -xsmp
+diff +linebreak +perl/dyn +terminal -xterm_clipboard
+digraphs +lispindent +persistent_undo +terminfo -xterm_save
For the record, I get the same error when sourcing my vimrc
once a markdown file is loaded in a buffer. The plugin works fine except from that.
I don't know of any ways to try a plugin in isolation. Can you point me towards anything?
@al3xandru You could try to disable all the settings you have for Markdown in your config, except for mkdx: comment out everything between line 1012 and 1136 in your vimrc linked above, but keep line 1022.
Run
:PlugClean
:PlugUpdate
and restart Vim.
Does it work now?
Thank you @al3xandru for your reply, I will check it out ASAP (got friends over tonight so will be tomorrow at best), well done on confirming that mkdx bindings are in fact mapped as well, this means it could be a bug in mkdx's enter handler (hope not though, ugliest code I ever wrote hehe :sweat_smile:).
And also @victorkristof thank you for checking this out and finding out what causes the g:mkdx#settings
error upon resourcing the vimrc file. Indeed this is an edge case which could probably be guarded against by checking if !exists('g:mkdx#settings') | g:mkdx#settings = ... | endif
.
Much appreciated feedback from both of you, I will try the vimrc when I can and report back :+1:
While I cannot offer a comprehensive confirmation of what works and what not, I'd say that:
majority of bindings work. The default prefix being <leader>
increases the chances for conflicts. As a suggestion, would it be safer to make the prefix localleader
instead?
what I cannot get to work is list completion on Enter
and o
. Amazingly, O
works :-).
2.1 :verbose map
displays the correct bindings for all 3 of them.
2.2 Looking at the code there seem to be significant difference between mkdx#OHandler
and mkdx#ShiftOHandler
. There doesn't seem to be any code in the former meant for list continuation, but my VimL knowledge is limited so I might be wrong.
2.3 Adding an echom "Inside mkdx#EnterHandler"
at line 1549 doesn't show in the :messages
which makes me think that the handler is actually not invoked.
@victorkristof @SidOfc can you share what version of vim are you using (not sure the OS matters)? On my system, neither terminal vim, nor MacVim accept settings in the format let g:mkdx#settings.enter.enable
complaining g:mkdx#settings
does not exist.
Hi @al3xandru,
I just took a quick look at your vimrc and disabled all plugins except mkdx (this more or less is "testing in isolation") so all other Plug github/repo
things were commented and some settings causing crashes due to missing plugin code were disabled too. (and some additional colorscheme commands I couldn't get to work on my machine).
The result was that mkdx worked as intended, both o
and enter
started working after I did that.
I do not know however, which plugin was in the way, you have quite a lot of config / plugins and it could take me a while to figure that out, I don't think I want to go through 1.5k lines of config either :sweat_smile:
Furthermore, about the settings; You are correct, you cannot define let g:mkdx#settings.map.prefix
as such in vimrc, these are only to be used for changing stuff on the fly after having initially loaded the plugin, I think I'll add a note about this in the README whenever I find the time.
To have your settings the way you want, may I suggest using this format instead:
let g:mkdx#settings = {
\ 'map': {
\ 'prefix': '<localleader>'
\ },
\ 'tokens': {
\ 'italic': '_'
\ }
\ }
As for the plugin situation, really the only way to find out is to disable all the plugins initially, then enable ones that enable themselves on markdown files.
Hopefully this helps in resolving your issue, since it doesn't seem to have to do with the vim version I think, but rather some plugin with about 99% certainty :)
For reference, this is your vimrc with my "tweaks" which did make it work (note: I did not check if localleader / italic token were actually applied properly, I think they will be):
scriptencoding utf-8
" Organization
" 1. important
" 2. moving around, searching and patterns
" 3. tags
" 4. displaying text
" 5. syntax, highlighting and spelling
" 6. multiple windows
" 7. multiple tab pages
" 8. terminal
" 9. using the mouse
" 10. printing
" 11. messages and info
" 12. selecting text
" 13. editing text
" 14. tabs and indenting
" 15. folding
" 16. diff mode
" 17. mapping
" 18. reading and writing files
" 19. the swap file
" 20. command line editing
" 21. executing external commands
" 22. running make and jumping to errors
" 23. language specific
" 24. multi-byte characters
" 25. various
" 1. important {{{
set nocompatible
set backspace=2
set backspace=indent,eol,start " allow backspace in insert mode
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
if has('clipboard')
if has('unnamedplus')
set clipboard^=unnamed,unnamedplus
else
set clipboard=unnamed
endif
endif
if !has('nvim')
set esckeys " allow cursor keys in insert mode
endif
set hidden " allow buffer switching without saving
set lazyredraw
set modeline
set modelines=5
set mouse=a
set mousehide
set sessionoptions-=options
set sessionoptions+=curdir
set showcmd " show command in bottom bar
set showmode " display the current mode
set wildmenu " enhance command-line completion
set wildignore+=.hg,.git,.svn " version control
set wildignore+=*.o,*.obj,*.exe,*.dll,*.pyc,*.pyo,*.class,*.luac " compiled
set wildignore+=*.DS_Store,*.sw?
set wildignore+=.idea/**
set wildignore+=*.png,*.jpg,*.gif,*.bmp
set wildignore+=*.egg,*.egg-info,*.gem
set wildignore+=*.zip,*.tar.gz,*.gzip,*.rar
set wildignore+=*.aux,*.toc " Latex intermediary files
" }}}
" 2. moving around, searching and patterns {{{
set ignorecase
set incsearch
set nohlsearch
set smartcase
set showmatch
set matchtime=3 " tenths of a second to show the matching paren
set scrolloff=5
" }}}
" 3. omnicomplete {{{
set infercase
set omnifunc=syntaxcomplete#Complete
" https://github.com/sjl/dotfiles/blob/eea18b00b8c74943f5094fddf91d3c2a7e0a7242/vim/vimrc#L534
" kspell: dictionary completion only when spell enabled set spell
set complete=.,w,b,u,t,i,kspell
" http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
set completeopt=longest,menu,preview
" http://stackoverflow.com/questions/7722177/how-do-i-map-ctrl-x-ctrl-o-to-ctrl-space-in-terminal-vim
inoremap
inoremap
" }}}
" 4. displaying text {{{
filetype on
filetype plugin on
filetype plugin indent on
set synmaxcol=500
set listchars=tab:▸\ ,trail:·,eol:¬
set showbreak=↪
" set showbreak=⤿
" line numbers {{{
" http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/
function! ToggleLineNo()
if(&relativenumber == 1)
set norelativenumber number
else
set number relativenumber
endif
endfunction
" mappings inspired by vim-unimpaired
nmap [o- :set number relativenumber
nmap ]o- :set norelativenumber number
nmap co- :call ToggleLineNo()
map :call ToggleLineNo()
augroup lineno
autocmd!
autocmd FocusLost * set norelativenumber number
autocmd InsertEnter * set norelativenumber number
autocmd InsertLeave * set relativenumber number
autocmd Filetype qf setlocal norelativenumber number nowrap
augroup END
set number
set relativenumber
set numberwidth=2 " keep the line number gutter narrow so 3 digits is cozy
" }}}
" }}}
" 5. syntax, highlighting and spelling" {{{
syntax on " enable syntax processing
" keyworkdprg, dictionary, thesaurus {{{
set dictionary=/usr/share/dict/words
set thesaurus+=~/.vim/mthesaur.txt
if has('mac') " unix, win32, win64
set keywordprg=:!open\ dict://\
else
set keywordprg=:!open\ https://www.google.com/search?q=\
endif
augroup keywordprog
autocmd!
autocmd FileType vim setlocal keywordprg=:help
augroup END
" }}}
" }}}
" 6. multiple windows {{{
set title
set laststatus=2
" http://got-ravings.blogspot.co.at/2008/08/vim-pr0n-making-statuslines-that-own.html
" Colors: Error, Question, Search, Todo, Visual, WarningMsg
set statusline=%q[%#Error#%{toupper(mode())}%*:b%n]\ %f%m%r
set statusline+=\ %#Todo#%{exists('g:loaded_fugitive')?fugitive#statusline():''}%*
set statusline+=%= "left/right separator
set statusline+=%#Todo#%{exists('g:loaded_obsession')?ObsessionStatus():''}%*
set statusline+=%y[%{&fileencoding?&fileencoding:&encoding}]
set statusline+=%<[%v:%l/%L][a\%03.3b:h\%02.2B]
" GUI {{{
" set guicursor=n-v-c:block-Cursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-lCursor,r-cr:hor20-Cursor,sm:block
set guioptions=aAce
set selection=exclusive
if has("gui_running")
set go-=T
set go-=l
set go-=L
set go-=r " no scrollbar
set go-=R
if has("gui_macvim")
" set gfn=Anonymous_Pro:h12
" set gfn=Consolas:h12
" set gfn=Cousine:h11
" set gfn=Fira_Code_Regular:h12
" set gfn=Hack:h12
" set gfn=Inconsolata:h13
" set gfn=Input_Mono:h11
" set gfn=Liberation_Mono:h11
set gfn=Operator_Mono:h12
" set gfn=PragmataPro_Mono:h13
" set gfn=Source_Code_Pro:h11
" set gfn=SF_Mono_Regular:h12 linespace=2
" add "New Window" menu to MacVim (stupid but needed)
" aun File.New\ Window
an 10.290 File.New\ Window :silent !mvim
macm File.New\ Window key=
elseif has("gui_gtk2")
set gfn=monofur\ 12,SourceCodePro\ 10,Anonymous\ Pro\ 10
endif
set columns=110
set lines=80
if &diff
set columns=180
endif
elseif has("gui_vimr")
set columns=110
set lines=80
endif
" augroup VimTransparency
" autocmd!
" autocmd FocusGained * set transparency=0
" autocmd FocusLost * set transparency=25
" augroup END
" }}}
" splits
set splitbelow
set splitright
" automatically open the location/quickfix window after :make, :grep,
" :lvimgrep and friends if there are valid locations/errors
"augroup qf
"autocmd QuickFixCmdPost [^l]* cwindow
"autocmd QuickFixCmdPost l* lwindow
"augroup END
" }}}
" 11. messages and info {{{
set ruler
set noerrorbells
set novisualbell
set t_vb=
if has("gui_macvim")
set visualbell t_vb=
endif
" }}}
" 14. tabs and indenting {{{
set expandtab " TABs are spaces
set tabstop=4 " number of visual spaces per TAB
set shiftwidth=4
set softtabstop=4 " number of spaces in TAB when editing
set smartindent
set autoindent
" }}}
" 15. folding {{{
set foldenable
set foldmethod=indent
set foldnestmax=10
set foldlevel=100
"HTML folding tag
nnoremap zha Vatzf
" }}}
" 16 diff mode
set diffopt=filler,vertical
" 17. mappings {{{
set timeoutlen=750
" abbreviations
cnoreabbrev W w
cnoreabbrev Q q
" leader = space (default \)
" localleader = ,
" remap ,
let mapleader="\"
let maplocalleader=","
" (I)Mapping: escape (disabled) {{{
" inoremap jk :echoerr "mapping disabled. forget about it :-)"i
" inoremap fd :w
" }}}
" (I)Mapping: disable arrows {{{
inoremap
inoremap
inoremap
inoremap
" }}}
" (I)Mappings: insert at end of line {{{
" insert at the end of line while in insert mode;
" i_CTRL-A is insert previously inserted text; i_CTRL-I is insert
inoremap A
inoremap A
inoremap å A
" Insert a newline in normal mode
" nnoremap O
" nnoremap o
" nnoremap i " Ctrl-j: break the line at cursor
" }}}
" (N)Mapings: buffers {{{
" https://www.reddit.com/r/vim/comments/4gjbqn/what_tricks_do_you_use_instead_of_popular_plugins/
nnoremap b :ls:buffer
" buffer switch (disabled) {{{
" nmap :bNext
" nmap :e#
" }}}
" }}}
" (N)Mappings: change (bind c[hange] to replace word under cursor) {{{2
nnoremap c :%s/\<\>//cg
" change word under cursor and use `.` to repeat (cheap rename refactor)
nnoremap c* *Ncgn
nnoremap c# #NcgN
nnoremap cg* g*Ncgn
nnoremap cg# g#NcgN
" }}}
" (N)Mappings: files {{{
" Opens an edit command with the path of the currently edited file filled in
nnoremap ef :e =expand("%:p:h") . "/"
nnoremap et :tabe =expand("%:p:h") . "/"
nnoremap es :split =expand("%:p:h") . "/"
nnoremap ev :vsplit =expand("%:p:h") . "/"
"Source: http://superuser.com/questions/132029/how-do-you-reload-your-vimrc-file-without-restarting-vim
nnoremap e. :tabe $MYVIMRC
nnoremap s. :source $MYVIMRC
" see also edit commands using extensions:
" open with CtrlP
" }}}
" (N)Mappings: highlights {{{
" Show special characters (highlighting)
nmap hc :set nolist!
" Disable highlighted search
nnoremap hh :nohlsearch
nnoremap :nohlsearch
" Highlight matches http://www.jeffcomput.es/posts/2016/02/vim-tips-helpful-leader-key-commands/
" case sensitive, partial match inclusive
nnoremap hi :set hlsearch:let @/=''
" case sensitive, no partial match
nnoremap ho :set hlsearch:let @/='\<\>'
" }}}
" (N)Mappings: moves by line {{{
" make vertical line nav better http://stackoverflow.com/questions/20975928/moving-the-cursor-through-long-soft-wrapped-lines-in-vim/21000307#21000307
" and add the jumplist https://medium.com/@kadek/understanding-vims-jump-list-7e1bfc72cdf0
nnoremap k (v:count == 0 ? 'gk' : "m'" . v:count . 'k')
nnoremap j (v:count == 0 ? 'gj' : "m'" . v:count . 'j')
nnoremap gk
nnoremap gj
" }}}
" (N)Mappings: n/N with blip, center the line, and directional {{{
" nnoremap n v:searchforward ? 'nzzzv:call HLNext(0.6)' : 'Nzzzv:call HLNext(0.6)'
" nnoremap N v:searchforward ? 'Nzzzv:call HLNext(0.6)' : 'nzzzv:call HLNext(0.6)'
nnoremap n 'Nn'[v:searchforward] . 'zzzv:call HLNext(0.6)'
nnoremap N 'nN'[v:searchforward] . 'zzzv:call HLNext(0.6)'
" http://vi.stackexchange.com/questions/2761/set-cursor-colour-different-when-on-a-highlighted-word
" Plug 'timakro/vim-searchant'
" nnoremap n nzzzv:call HLNext(0.6)
" nnoremap N Nzzzv:call HLNext(0.6)
" directional n/N
" nnoremap n 'Nn'[v:searchforward]
" nnoremap N 'nN'[v:searchforward]
function! HLNext (blinktime)
let l:target_pat = '\c\%#'.@/
let l:ring = matchadd('ErrorMsg', l:target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(l:ring)
redraw
endfunction
" }}}
" nnoremap ; getcharsearch().forward ? ';' : ','
" nnoremap , getcharsearch().forward ? ',' : ';'
" (N)Mappings: search with grep {{{
" bind f and F to perform grep for the word under cursor
" grep results go into quicklist: copen/cclose
nnoremap /fg :grep! -R '' =getcwd()
nnoremap /fG :grep -R '' =expand("%:p:h")
"nnoremap F :vimgrep! /\C\<\>/gj =expand("%:p:h")
"nnoremap F :vimgrep! /\<\>/j
" }}}
" (N)Mappings: search [I/]I {{{2
nnoremap [I [I:let nr = input("Jump to: ")exe "normal " . nr ."[\t"
nnoremap ]I ]I:let nr = input("Jump to: ")exe "normal " . nr ."]\t"
" 2}}}
" See (N)Mappings: search with ack/ag
" Mappings: selections {{{
" reselect pasted text
nnoremap v V`]
" https://github.com/henrik/dotfiles/blob/master/vim/config/mappings.vim#L22
" select the text that was last edited/pasted
" http://vimcasts.org/episodes/bubbling-text/
nmap gV `[v`]
" keep selection when indenting
vnoremap > >gv
vnoremap < gt :tabs:tabn
nnoremap :silent tabprevious
nnoremap :silent tabnext
inoremap :tabprevious
inoremap :tabnext
" open tag in tab
nnoremap T
inoremap T
" Alt+] on OS X
nmap
imap
if (has('mac') || has('macunix')) && has('gui')
nmap ‘
imap ‘
endif
" }}}
" Mappings: window resizing {{{
nmap < :vertical resize -10
nmap > :vertical resize +10
nmap - :resize -10
nmap + :resize +10
" }}}
" (C)Mappings: Inserts the path of the currently edited file into a command {{{
cnoremap =expand("%:p:h") . "/"
cnoremap =expand("%:t")
" }}}
" (C)Mappings: Save current session {{{
function! SaveSession()
let l:parentDir = getcwd()
let l:sessionFile = expand("~/.sessions/vim/") . strftime("%Y-%m-%dT%H%M%S") . "_" . join(split(l:parentDir, "/"),"~") . ".vim"
echom "Parent dir :" . l:parentDir
echom "Session file:" . l:sessionFile
" exec "mksession! " . l:parentDir . "/.session.vim"
" echo "session saved " . l:parentDir . "/.session.vim"
if isdirectory(l:parentDir . "/.git")
let l:sessionFile = l:parentDir . "/.git/.session.vim"
endif
if exists("g:loaded_obsession")
exec "Obsession " . l:sessionFile
else
exec "mksession! " . l:sessionFile
endif
echom "session saved in " . l:sessionFile
endfunction
cnoremap call SaveSession()
nnoremap :call SaveSession()
cnoremap call SaveSession()
nnoremap :call SaveSession()
"cnoremap ="mksession! " . getcwd() . "/.session.vim"
"cnoremap ="mksession! " . expand("%:p:h") . "/.session.vim"
" }}}
" disable auto-sourcing of $MYVIMRC
" augroup myvimrc
" au!
" au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
" augroup END
" }}}
" 19. backup & swap file {{{
set backup
set noswapfile
set undofile
set history=10000
set backupdir=~/.vim/tmp/backup// "~/.vim/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim/tmp/swap// "~/.vim/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set undodir=~/.vim/tmp/undo//
set writebackup
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
"}}}
" 24. multi-byte characters
setglobal fileencoding=utf-8
set encoding=utf-8 nobomb
" autocmds
if has("autocmd")
augroup vimrc
autocmd!
" autosave on focus lost
autocmd FocusLost, BufLeave * silent! :wall
" default to markdown if not in diff mode
autocmd BufEnter * if &filetype == "" && !&diff | setlocal ft=markdown | endif
" crontab -e
autocmd BufNewFile,BufRead crontab.* set nobackup nowritebackup
" json is javascript
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
autocmd FileType html,htm setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType make setlocal ts=4 sts=4 sw=4 noexpandtab
autocmd FileType java setlocal omnifunc=javacomplete#Complete
autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab autoindent
autocmd FileType vim setlocal nowrap
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
if filereadable(expand("~/.vim/bundle/HTML-AutoCloseTag/ftplugin/html_autoclosetag.vim"))
autocmd FileType html,htm,xhtml,xml source ~/.vim/bundle/HTML-AutoCloseTag/ftplugin/html_autoclosetag.vim
end
augroup END
end
" https://github.com/macvim-dev/macvim/issues/386
if has('mac')
if executable("pyenv") && !has('nvim')
" v.1
" let _cmd = 'pyenv version-name'
" let _pyenv=substitute(system(_cmd), '[\]\|[[:cntrl:]]', '', 'g')
" v.2
" let _cmd = 'python -c "import sys;vt=sys.version_info;sys.stdout.write(\".\".join([str(v) for v in vt[:3]]))"'
" let _pyver=substitute(system(_cmd), '[\]\|[[:cntrl:]]', '', 'g')
" check: https://github.com/macvim-dev/macvim/blob/b906f87e8c0ef8585e5aaeb72ca4aadbbd1b8155/src/MacVim/vimrc#L21
" Python 2
let _cmd = 'pyenv versions --bare --skip-aliases | grep -E "2\.[[:digit:]]+\.[[:digit:]]+$" | tail -1'
let _pyenv=substitute(system(_cmd), '[\]\|[[:cntrl:]]', '', 'g')
let _pyver=substitute(_pyenv, '^\s*\(.*\)', '\1', '')
let _pyvermaj=join(split(_pyver, "\\.")[0:1], ".")
let &pythondll=$HOME . "/.pyenv/versions/" . _pyver . "/lib/libpython" . _pyvermaj . ".dylib"
let &pythonhome=$HOME . "/.pyenv/versions/" . _pyver
" Python 3
let _cmd = 'pyenv versions --bare --skip-aliases | grep -E "3\.[[:digit:]]\.[[:digit:]]+$" | tail -1'
let _pyenv=substitute(system(_cmd), '[\]\|[[:cntrl:]]', '', 'g')
let _pyver=substitute(_pyenv, '^\s*\(.*\)', '\1', '')
" let _pyver=_pyenv
" following line replaced by next one dealing better with versions
" let _pyvermaj=strpart(_pyver, 0, 3)
let _pyvermaj=join(split(_pyver, "\\.")[0:1], ".")
" I don't know how to do set pythondll thus the let &pythondll
let &pythonthreehome = $HOME . "/.pyenv/versions/" . _pyver
let &pythonthreedll = $HOME . "/.pyenv/versions/" . _pyver . "/lib/libpython" . _pyvermaj . ".dylib"
" echom "&pythonhome :" . &pythonhome
" echom "&pythondll :" . &pythondll
" echom "&pythonthreehome:" . &pythonthreehome
" echom "&pythonthreedll :" . &pythonthreedll
" http://stackoverflow.com/questions/30443836/install-vim-via-homebrew-with-python-and-python3-support
if _pyvermaj > '3.0' && has('python3')
" echom "PYTHON3k :YES"
let g:jedi#force_py_version = 3
let g:pymode_python = 'python3'
else
" echom "PYTHON3k :NO"
let g:jedi#force_py_version = 2
let g:pymode_python = 'python'
endif
endif
endif
function! BigWnd()
" colorscheme nuvola
" set gfn=Operator_Mono:h24
set gfn=mononoki:h24
set colorcolumn=0
set columns=80
" edit "~/Desktop/" . strftime("%Y%m%d-%H%M") . ".md"
exec "edit ~/Dropbox/Dox/mydox/tmp-" . strftime("%Y%m%d-%H%M") . ".md"
startinsert
endfunction
command! Bigwnd call BigWnd()
function! Fonts()
let l:fonts = "Anka/Coder_Narrow Cousine Fira_Code Go_Mono Hack IBM_Plex_Mono Iosevka JetBrains_Mono mononoki Operator_Mono PragmataPro_Mono Source_Code_Pro"
let l:flst = split(l:fonts)
echo "Fonts:"
echo join(l:flst, "\n")
echo "\n"
exec "set gfn=" . input("Font: ", "mononoki") . ":h" . input("Size: ", "24")
endfunction
command! SetFont call Fonts()
" Load vim-plug https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged-al3xandru')
" Alternative plugin managers
" - vundle
" - junegunn/vim-plug
" - Shougo/neobundle.vim
" colorschemes {{{1
" Plug 'vim-scripts/Colour-Sampler-Pack'
" sources {{{2
" https://www.reddit.com/r/neovim/comments/e04207/what_are_the_best_maintained_and_most_extensive/ " {{{2
" https://www.reddit.com/r/neovim/comments/ehjsbk/looking_for_good_light_colorscheme/
" }}}
" top (supporting text styling) {{{2
" Plug 'morhetz/gruvbox'
" Plug 'gruvbox-community/gruvbox'
" light
" Plug 'NLKNguyen/papercolor-theme'
" dark
" Plug 'arcticicestudio/nord-vim'
" Plug 'joshdick/onedark.vim'
" Plug 'trevordmiller/nova-vim'
" }}}
" ok {{{2
" Plug 'AlessandroYorba/Alduin'
let g:alduin_Shout_Aura_Whisper = 1
let g:alduin_Shout_Fire_Breath = 1
" light
" Plug 'nice/sweater'
" Plug 'zefei/cake16'
" }}}
" simple light {{{2
" Plug 'arzg/vim-colors-xcode'
" Plug 'arzg/vim-plan9'
" Plug 'ayu-theme/ayu-vim'
let ayucolor="light" "options: light mirage dark
" Plug 'cormacrelf/vim-colors-github'
let g:github_colors_soft = 1
" Plug 'jaredgorski/fogbell.vim'
" Plug 'rakr/vim-one'
let g:one_allow_italics = 1
" simplified and optimized Gruvbox
" Plug 'lifepillar/vim-gruvbox8'
" }}}
"}}}
" disabled colorschemes {{{2
" Plug 'adampasz/vim-stonewashed'
" Plug 'AlessandroYorba/Sierra'
" Plug 'altercation/vim-colors-solarized'
let g:solarized_termtrans=0
let g:solarized_termcolors=256
let g:solarized_visibility="high"
let g:solarized_contrast="normal"
" Plug 'blerins/flattown'
" Plug 'chriskempson/base16-vim'
" Plug 'cocopon/iceberg.vim'
" Plug 'colepeters/spacemacs-theme.vim'
" Plug 'fcpg/vim-fahrenheit'
" Plug 'fenetikm/falcon'
" Plug 'freeo/vim-kalisi'
" Plug 'jdkanani/vim-material-theme'
" Plug 'jeetsukumaran/vim-nefertiti'
" Plug 'jonathanfilip/vim-lucius'
" After enabling: :Lucius[Black|BlackHighContrast|BlackLowContrast|
" Dark|DarkHighContrast|DarkLowContrast|Light|LightLowContrast|
" White|WhiteLowContrast]
" Plug 'junegunn/seoul256.vim'
" Plug 'lifepillar/vim-wwdc17-theme'
" Plug 'mayansmoke'
" Plug 'mhartington/oceanic-next'
" Plug 'nanotech/jellybeans.vim'
" Plug 'NLKNguyen/papercolor-theme'
" Plug 'rakr/vim-two-firewatch'
let g:two_firewatch_italics=1
let g:airline_theme='twofirewatch'
" Plug 'rodnaph/vim-color-schemes'
" Plug 'swalladge/antarctic-vim'
" Plug 'whatyouhide/vim-gotham'
" Plug '256-grayvim'
" Plug 'blacklight'
" Plug 'gregsexton/Atom'
" Plug 'zeis/vim-kolor'
" }}}
" }}}
" Extra text objects {{{1
" Plug 'kana/vim-textobj-user'
" Line object: il al
" Plug 'kana/vim-textobj-line'
" Function argument object: i, a,
" Shift: <, >,
" Jump: [, ],
" Plug 'PeterRincker/vim-argumentative'
" Plug 'argtextobj.vim'
" Indent object: ii ai aI iI
" Plug 'michaeljsmith/vim-indent-object'
" Function call object: am im aM iM
" Plug 'thalesmello/vim-textobj-methodcall'
" Function object: if af iF aF
" Plug 'kana/vim-textobj-function'
" Plug 'kamichidu/vim-textobj-function-go'
" Plug 'thinca/vim-textobj-function-javascript'
" Plug 'thinca/vim-textobj-function-perl'
" Plug 'nelstrom/vim-textobj-rubyblock'
" Comment object: ic ac aC
" Plug 'glts/vim-textobj-comment'
" URIs: iu au
" Plug 'jceb/vim-textobj-uri'
" Plug 'wellle/targets.vim'
" }}}
" Essentials {{{1
"
" Files {{{2
"{{{3
" Plug 'ctrlpvim/ctrlp.vim'
let g:loaded_ctrlp = 1
let g:ctrlp_map = ''
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_match_window = 'top,order:ttb,min:1,max:10,results:10'
" only cache if we're over this number of files
let g:ctrlp_use_caching = 2000
" Mappings: CtrlP {{{4
" nnoremap o :CtrlP
" nnoremap ] :CtrlPBufTag
" nnoremap B :CtrlPBuffer
" " open with CtrlP
" nnoremap eT :tabnew:CtrlP
" nnoremap eS :split
This will probably sounds a little odd, but after adding the plugin to my
.vimrc
and installing it, I cannot tell if the plugin is actually active or not.<Prefix>t
doesn't seem to check a checkbox:echo g:mkdx#settings
displays a bunch of settings.How can I check if the plugin is active?