diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-07-28 21:52:02 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-07-28 21:52:02 -0300 |
commit | a3653e9be15357f2813543c5ff320327b6f04531 (patch) | |
tree | 289bd881e341768bd8dfa89f7e874ac8a3d22511 | |
parent | 520351e0b4aa06be5d72c89aec73e218fa2ea044 (diff) | |
download | vim-a3653e9be15357f2813543c5ff320327b6f04531.tar.gz vim-a3653e9be15357f2813543c5ff320327b6f04531.tar.bz2 |
Fix: workarounds for markdown filetype handling
-rw-r--r-- | vim.dot.link/filetype.vim | 71 | ||||
-rw-r--r-- | vim.dot.link/ftplugin/markdown.vim | 23 |
2 files changed, 71 insertions, 23 deletions
diff --git a/vim.dot.link/filetype.vim b/vim.dot.link/filetype.vim index f3c90bb..f90f920 100644 --- a/vim.dot.link/filetype.vim +++ b/vim.dot.link/filetype.vim @@ -1,42 +1,77 @@ " Vim support file to detect file types +" Check if file type config is already loaded {{{ if exists("did_load_filetypes") finish endif +" }}} -" VIM filetype -augroup filetype_vim - autocmd! - autocmd FileType vim setlocal foldmethod=marker -augroup END - -" Filetype detection +" Filetype detection {{{ " " According to ":help BufRead", this augroup is also evaluated also on " ":filetype detect". augroup filetypedetect autocmd! - autocmd BufRead,BufNewFile kvmxfile setfiletype sh - autocmd BufRead,BufNewFile Vagrantfile setfiletype ruby - autocmd BufRead,BufNewFile *.vue setfiletype html - autocmd BufRead,BufNewFile *.thtml setfiletype php + + " Calendar autocmd BufRead,BufNewFile *.rem setfiletype remind + + " Trac autocmd BufRead,BufNewFile *.trac setfiletype tracwiki autocmd BufRead,BufNewFile *.tracwiki setfiletype tracwiki - autocmd BufRead,BufNewFile *.mdwn setfiletype markdown - autocmd BufRead,BufNewFile *.md setfiletype markdown + + " Programming languages + autocmd BufRead,BufNewFile kvmxfile setfiletype sh + autocmd BufRead,BufNewFile Vagrantfile setfiletype ruby autocmd BufRead,BufNewFile *.py setfiletype python autocmd BufRead,BufNewFile *.pp setfiletype puppet autocmd BufRead,BufNewFile *.php setfiletype php + autocmd BufRead,BufNewFile *.thtml setfiletype php + autocmd BufRead,BufNewFile *.vue setfiletype html + + " Markdown + " + " This handling is disabled by default, since it may be conflicting + " with something. + " + " Markdown folding through NestedMarkdownFolds() are not correctly working + " with this configuration. + " + "autocmd BufRead,BufNewFile,BufEnter *.mdwn setfiletype markdown + "autocmd BufRead,BufNewFile,BufEnter *.md setfiletype markdown +augroup END +" }}} + +" Markdown workaround {{{ +" +" Since the following configuration is not working at ftplugin/markdown.vim, +" it's being used here. +" +" Also note that BufEnter event also need to be included, otherwise foldings +" won't be correctly applied in some Markdown files loaded in new windows. +augroup filetype_markdown + autocmd! + autocmd BufRead,BufNewFile,BufEnter *.md set foldexpr=NestedMarkdownFolds() + autocmd BufRead,BufNewFile,BufEnter *.md set autoindent smartindent tabstop=2 softtabstop=2 shiftwidth=2 expandtab formatoptions=tcroqn2 comments=n:> +augroup END +" }}} + +" VIM filetype {{{ +augroup filetype_vim + autocmd! + autocmd FileType vim setlocal foldmethod=marker augroup END +" }}} -" Drupal *.module and *.install files. +" Drupal {{{ +" Handle *.module, *.install, *.profile etc if has("autocmd") augroup filetype_drupal autocmd! - autocmd BufRead,BufNewFile *.profile setfiletype php - autocmd BufRead,BufNewFile *.module setfiletype php - autocmd BufRead,BufNewFile *.install setfiletype php - autocmd BufRead,BufNewFile *.test setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.profile setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.module setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.install setfiletype php + autocmd BufRead,BufNewFile,BufEnter *.test setfiletype php augroup END endif +" }}} diff --git a/vim.dot.link/ftplugin/markdown.vim b/vim.dot.link/ftplugin/markdown.vim index 99d0ed3..366d9f2 100644 --- a/vim.dot.link/ftplugin/markdown.vim +++ b/vim.dot.link/ftplugin/markdown.vim @@ -1,20 +1,33 @@ " Markdown configuration +" +" This filetype script is currently disable, as it may be conflicting with +" something else. +" +" Markdown folding through NestedMarkdownFolds() are not correctly working +" with this configuration. +" +" These settings are configured directly on filetype.vim instead. + +" Basic {{{ +"set autoindent smartindent tabstop=2 softtabstop=2 shiftwidth=2 +"set expandtab formatoptions=tcroqn2 comments=n:> +" }}} -" Markdown configuration without vim-markdown plugin +" Markdown configuration without vim-markdown plugin {{{ " " Include folding setup: " https://github.com/masukomi/vim-markdown-folding " " Alternative folding method: " https://codereview.stackexchange.com/questions/202620/vim-plugin-for-folding-markdown-lists -set foldexpr=NestedMarkdownFolds() -set autoindent smartindent tabstop=2 softtabstop=2 shiftwidth=2 -set expandtab formatoptions=tcroqn2 comments=n:> +"set foldexpr=NestedMarkdownFolds() +" }}} -" Markdown configuration with vim-markdown plugin +" Markdown configuration with vim-markdown plugin {{{ "set autoindent smartindent tabstop=2 softtabstop=2 shiftwidth=2 expandtab formatoptions=tcroqn2 comments=n:> "let g:vim_markdown_new_list_item_indent = 2 "let g:vim_markdown_folding_style_pythonic = 1 "let g:vim_markdown_folding_level = 1 "let g:vim_markdown_auto_insert_bullets = 0 "let g:vim_markdown_new_list_item_indent = 0 +" }}} |