git: cab164f987 - main - Update vim config for adoc files
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 28 Jun 2022 07:44:25 UTC
The branch main has been updated by bofh (ports committer): URL: https://cgit.FreeBSD.org/doc/commit/?id=cab164f9878a93df4fb10f49939a991c46fb283e commit cab164f9878a93df4fb10f49939a991c46fb283e Author: Muhammad Moinur Rahman <bofh@FreeBSD.org> AuthorDate: 2022-06-28 07:40:09 +0000 Commit: Muhammad Moinur Rahman <bofh@FreeBSD.org> CommitDate: 2022-06-28 07:40:09 +0000 Update vim config for adoc files In the en/books/fdp-primer/book/#editor-config-vim section the vim configuration is outdated and misinformed: - vim-tiny do not come with syntax highlighting files so recommending that might be counter-productive - For advanced users advise ale linter - Split the functions for two different purposes: adoc and man - There is no concept of wrapping in adoc as we are following the rule "one sentence one line". On the other hand man pages should have a wrap at around 72 considering the historical purpose. So remove wrapping(Press[P]) from adoc and use only for man - There is also no usage of TAB too in adoc so accompany the(Press[T]) only for man and remove from adoc - Extra White Spaces should be applicable for both adoc and man while OverLength marker should be only for man - Use appropriate syntax and filetype for asciidoc and man PR: 264921 Approved by: crees --- .../en/books/fdp-primer/editor-config/_index.adoc | 84 +++++++++++++--------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/documentation/content/en/books/fdp-primer/editor-config/_index.adoc b/documentation/content/en/books/fdp-primer/editor-config/_index.adoc index d034d87737..bb3314bee6 100644 --- a/documentation/content/en/books/fdp-primer/editor-config/_index.adoc +++ b/documentation/content/en/books/fdp-primer/editor-config/_index.adoc @@ -52,13 +52,15 @@ Adjusting your text editor configuration can make working on document files quic [[editor-config-vim]] == Vim -Install from package:editors/vim[], package:editors/vim-console[], or package:editors/vim-tiny[] then follow the configuration instructions in <<editor-config-vim-config>>. +Install from package:editors/vim[], or package:editors/vim-console[], then follow the configuration instructions in <<editor-config-vim-config>>. +More advanced users can use a proper linter like link:https://github.com/dense-analysis/ale[Ale] which can also act as a Vim link:https://langserver.org/[Language Server Protocol] client. [[editor-config-vim-use]] === Use -Press kbd:[P] to reformat paragraphs or text that has been selected in Visual mode. -Press kbd:[T] to replace groups of eight spaces with a tab. +Manual page writers can use the following keyboard shortcuts to reformat: +* Press kbd:[P] to reformat paragraphs or text that has been selected in Visual mode. +* Press kbd:[T] to replace groups of eight spaces with a tab. [[editor-config-vim-config]] === Configuration @@ -68,43 +70,59 @@ Edit [.filename]#~/.vimrc#, adding these lines to the end of the file: [.programlisting] .... if has("autocmd") - au BufNewFile,BufRead *.sgml,*.ent,*.xsl,*.xml call Set_SGML() - au BufNewFile,BufRead *.[1-9] call ShowSpecial() + au BufNewFile,BufRead *.adoc call Set_ADOC() + au BufNewFile,BufRead *.[1-9] call Set_MAN() endif " has(autocmd) function Set_Highlights() - "match ExtraWhitespace /^\s* \s*\|\s\+$/ - highlight default link OverLength ErrorMsg - match OverLength /\%71v.\+/ - return 0 -endfunction " Set_Highlights() + "match ExtraWhitespace /^\s* \s*\|\s\+$/ + return 0 +endfunction " Set_Highlights_Adoc() + +function Set_Highlights_MAN() + highlight default link OverLength ErrorMsg + match OverLength /\%71v.\+/ + return 0 +endfunction " Set_Highlights_MAN() function ShowSpecial() - setlocal list listchars=tab:>>,trail:*,eol:$ - hi def link nontext ErrorMsg - return 0 + setlocal list listchars=tab:>>,trail:*,eol:$ + hi def link nontext ErrorMsg + return 0 endfunction " ShowSpecial() -function Set_SGML() - setlocal number - syn match sgmlSpecial "&[^;]*;" - setlocal syntax=sgml - setlocal filetype=xml - setlocal shiftwidth=2 - setlocal textwidth=70 - setlocal tabstop=8 - setlocal softtabstop=2 - setlocal formatprg="fmt -p" - setlocal autoindent - setlocal smartindent - " Rewrap paragraphs - noremap P gqj - " Replace spaces with tabs - noremap T :s/ /\t/<CR> - call ShowSpecial() - call Set_Highlights() - return 0 -endfunction " Set_SGML() +function Set_COMMON() + setlocal number + setlocal shiftwidth=2 + setlocal tabstop=8 + setlocal softtabstop=2 + setlocal formatprg="fmt -p" + setlocal autoindent + setlocal smartindent + call ShowSpecial() + call Set_Highlights() + return 0 +endfunction " Set_COMMON() + +function Set_ADOC() + setlocal syntax=asciidoc + setlocal filetype=asciidoc + call Set_COMMON() + return 0 +endfunction " Set_ADOC() + +function Set_MAN() + setlocal syntax=man + setlocal filetype=man + setlocal textwidth=70 + " Rewrap paragraphs + noremap P gqj + " Replace spaces with tabs + noremap T :s/ /\t/<CR> + call Set_COMMON() + call Set_Highlights_MAN() + return 0 +endfunction " Set_Man() .... [[editor-config-emacs]]