How do I display icons in VIM - vim

I'm looking to set up vim to display icons in my NerdTree pane.
I have it set as:
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
It would be similar to how VSCode is set.
Which display correctly here but not in my terminal it just has [x].
Is there a setting I can change?
I'm trying to set it up so that each file type has its own icon and git status for the file is visually shown.
I ended up installing a nerd font and airline now everything works.

I recommend using vim-devicons

Related

Vim markdown navigation with ctags: using 'tagbar' + 'markdown2ctags' with 'vim-pandoc'

All,
I'd like to be able to use the Vim Tagbar plugin with markdown2ctags to navigate my markdown files.
I haven't been able to automatically generate the tags file because the filetype, per :set filetype? is currently set to pandoc. That's becaue I have the the vim-pandoc plugin installed. However, if I change the filtype to markdown everything works.
I have control over two items: my ~/.vimrc file and my ~/.ctags file. Does anyone have an idea of how things should be set? I've tried changing markdown to pandoc in the excerpts below, but that didn't help.
Edit: As per the comment by #IngoKarkat, because markdown2ctags is handling the creation of my tags file, the .ctags settings are irrelevant.
From my ~/.vimrc file... (set as per the Tagbar instructions for markdown files)
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : '~/.vim/plugged/markdown2ctags/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes --sro=»',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '»',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0
\ }
...and my ~/.ctags file (Edit: Unused, but still including)
--langdef=markdown
--langmap=markdown:.mkd
--regex-markdown=/^#[ \t]+(.*)/\1/h,Heading_L1/
--regex-markdown=/^##[ \t]+(.*)/\1/i,Heading_L2/
--regex-markdown=/^###[ \t]+(.*)/\1/k,Heading_L3/
Thanks,
Sean
I found a few solutions to the problem. I've listed them here in case someone finds them useful.
Solution 1: Re-define the pandoc filetype to the markdown filetype
I looked at the vim-pandoc pandoc.txt file and the solution was there. The relevant information:
To enable pandoc functionality for markdown files while using the markdown
filetype and syntax, use
>
let g:pandoc#filetypes#handled = ["pandoc", "markdown"]
let g:pandoc#filetypes#pandoc_markdown = 0
Note: vim-pandoc's developers mostly use pandoc's markdown syntax, so
coverage for it is more complete than for the other filetypes.
With the filetype now correctly set, everything works. The ~/.vimrc should be (with appropriate substitution for your own ctagsbin path):
let g:pandoc#filetypes#handled = ["pandoc", "markdown"]
let g:pandoc#filetypes#pandoc_markdown = 0
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : '~/.vim/plugged/markdown2ctags/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes --sro=»',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '»',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0
\ }
Solution 2: Define a new pandoc tagbar type
Add the following to your ~/.vimrc
let g:tagbar_type_pandoc = {
\ 'ctagstype': 'pandoc',
\ 'ctagsbin' : '~/.vim/plugged/markdown2ctags/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes --sro=»',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '»',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0
\ }
Everything should work! This is my preferred solution.
Solution 3: Use the builtin pandoc :TOC command.
The vim-pandoc :TOC command produces a navigational menu, however, I don't like it as well as the sidebar tagbar menus. But it is a built in default.

Write ctags support for diff/patch file in vim

I often use this in my project, to see changes :
git diff 5b80e3be314143f 3b34d24a55ab -- include/* src/* | vim -
All the lines starting with the file being changes are written like this:
diff --git a/include/behaviors/mechanical/crystal_behavior.h b/include/behaviors/mechanical/crystal_behavior.h
I would like to be able to navigate easily the files with tagbar, which uses ctags, and obtain for instance the filename, here crystal_behavior.h.
So, I know I can use something like this in a .ctags file:
--langdef=diff
--langmap=diff:.diff
--regex-diff=/^diff --git .*b\/(.*)(\/(.*))+$/\.\. \2/d,file/
Together with this in my .vimrc
let g:tagbar_type_diff = {
\ 'ctagstype' : 'diff',
\ 'kinds' : [
\ 'd:Files',
\ ],
\ 'sort' : 0,
\ }
My problem here is what can I put in here --regex-diff=*, to obtain filename? (I got more or less)
Is it possible to go further and also tag the hunks in each files? This is the most tricky part I cannot get.
Thank you
Bonus question: If I read the diff directly from buffer, tagbar doesn't generate tags. Whereas if I do git diff ...... > patch.diff, and then vim patch.diff, it works.
Universal-ctags(https://ctags.io) has a built-in parser for diff imported from geany:
[jet#localhost tmp]$ cat foo.diff
diff --git a/source.mak b/source.mak
index 2550028..eaa9154 100644
--- a/source.mak
+++ b/source.mak
## -44,6 +44,7 ## PARSER_SOURCES = \
$(PARSER_DIR)/clojure.c \
$(PARSER_DIR)/css.c \
$(PARSER_DIR)/cobol.c \
+ $(PARSER_DIR)/diff.c \
$(PARSER_DIR)/dosbatch.c \
$(PARSER_DIR)/eiffel.c \
$(PARSER_DIR)/erlang.c \
[jet#localhost tmp]$ ~/var/ctags/ctags --fields=+K --sort=no -o - foo.diff
a/source.mak foo.diff /^--- a\/source.mak$/;" modifiedFile
-44,6 +44,7 foo.diff /^## -44,6 +44,7 ## PARSER_SOURCES = \\$/;" hunk modifiedFile:a/source.mak

Systemverilog Support in tagbar plugin

can anybody help me to add systemverilog language support in tagbar vim plugin.
I tried below things but its doesnt worked for me
1) Created ~/.ctags and copy code from https://github.com/shaohao/config.d/blob/master/ctags
2) mkdir ftplugin to ~/.vim and add systemverilog.vim from https://github.com/shaohao/vimfiles/blob/master/bundle/verilog_systemverilog/ftplugin/systemverilog.vim
3)cd to project directory and run ctags -R *
Got below warning though
ctags: Warning: Unknown language specified in "langmap" option
Below are some output of ctags
ctags --list-languages
ctags: Warning: Unknown language specified in "langmap" option
.
.
systemverilog
ctags --list-kinds=systemverilog
ctags: Warning: Unknown language specified in "langmap" option
e clocking
i constraint
l covergroup
o class
t function
A interface
G module
J package
M program
W task
But still when i open SV file in gvim and use :TagbarToggle tagbar window is blank :(
Please help
I've introduced some improvements to the verilog_systemverilog vim plugin that I made available at Github. You should have proper Tagbar support if you use this development version of exuberante-ctags together with my vim plugin and the following Tagbar configuration:
let g:tagbar_type_verilog_systemverilog = {
\ 'ctagstype' : 'SystemVerilog',
\ 'kinds' : [
\ 'b:blocks:1:1',
\ 'c:constants:1:0',
\ 'e:events:1:0',
\ 'f:functions:1:1',
\ 'm:modules:0:1',
\ 'n:nets:1:0',
\ 'p:ports:1:0',
\ 'r:registers:1:0',
\ 't:tasks:1:1',
\ 'A:assertions:1:1',
\ 'C:classes:0:1',
\ 'V:covergroups:0:1',
\ 'I:interfaces:0:1',
\ 'M:modport:0:1',
\ 'K:packages:0:1',
\ 'P:programs:0:1',
\ 'R:properties:0:1',
\ 'T:typedefs:0:1'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'm' : 'module',
\ 'b' : 'block',
\ 't' : 'task',
\ 'f' : 'function',
\ 'C' : 'class',
\ 'V' : 'covergroup',
\ 'I' : 'interface',
\ 'K' : 'package',
\ 'P' : 'program',
\ 'R' : 'property'
\ },
\ }
Background: TagBar won't use your tags file, it queries ctags and read its output directly from stdout.
I believe the problem is how the --langmap is defined in your ~/.ctags. AFAIK, the coma is used to separate langmaps while different extensions are just put one after the other without separators:
--langmap=foo:.foo.fo.oo,bar:.bar.ba
I think line 2 of your ~/.ctags file should look like this:
--langmap=systemverilog:.sv.svh.svp

Hide text segments in vim for use in external commands

I am trying to create some sort of an ncurses-like menu appearence in vim.
Each line should have two fields: title, command
I read the input from stdin, formatted like: title COMMAND: command
item 1 COMMAND: echo hey
item 2 COMMAND: ls /
item 3 COMMAND: some-other-command
I want to show only the titles, like so:
item 1
item 2
item 3
But then I want to be able to run the command of this line, like so:
:.w !exec $(sed -r 's/COMMAND: (.*)/\1/')
But I haven't been able to hide the "COMMAND: ..." part.
How can I accomplish this?
Is vim not suited for such adventures?
Thank you...
Here is how to accomplish what you originally intended. There are many options but I personally use the Unite plugin.
Install Unite
Add the following in your vimrc too see possibilities:
let g:unite_source_menu_menus = {}
let g:unite_source_menu_menus.filters = {
\'description' : 'Text filters',
\'command_candidates' : [
\ ["Remove empty lines" , 'v/./d'],
\ ["Remove empty lines [v]" , "'<,'>v/./d"],
\ ['Condense empty lines' , '%s/\n\{3,}/\r\r/e'],
\ ['Remove trailing white space' , '%s/\s\+$//' ],
\ ['',''],
\]}
let g:unite_source_menu_menus.git = {
\ 'description' : 'Git commands (Fugitive)',
\ 'command_candidates' : [
\ ['git status (Fugitive) ' , 'Gstatus'],
\ ['git diff (Fugitive) ' , 'Gdiff'],
\ ['git commit (Fugitive) ' , 'Gcommit'],
\ ['git cd (Fugitive) ' , 'Gcd'],
\ ['',''],
\ ['git view file (gitv) ' , 'Gitv!'],
\ ['git view all (gitv) ' , 'Gitv'],
\]}
let g:unite_source_menu_menus.myhelp = {
\'description' : 'Interesting help topics',
\'command_candidates' : [
\ ['Executing shell commands in a window', 'h shell-window'],
\ ['File Searching and **', 'h starstar'],
\ ['Local directory .vimrc', "h 'exrc'"]
\]}
noremap <silent> sm :<C-u>Unite -no-start-insert -quick-match -buffer-name=menu menu<CR>
You can launch menu with sm. You can change menu options and you can execute, edit, bookmark and do other tasks with commands. There is an option to filter items and use fuzzy search engine.
Unite is unbelievable awesome plugin with many other benefits.
Another option is to use Forms plugin.
As for custom solution, this is a fast idea:
Given the file awesome.menu
item 11 COMMAND: echo 'hey'
item 2 COMMAND: !ls /
item 3 COMMAND: version
you can use the following function.
fu! Menu()
let g:menu_bg = synIDattr(hlID('Normal'), 'bg#')
let g:menu_fg = synIDattr(hlID('Normal'), 'fg#')
let g:menu_s = 1
exe 'highlight MyMenu guifg=' g:menu_fg
match MyMenu /COMMAND:.*/
nn <buffer> <space> :let g:menu_s = !g:menu_s<cr>:exe 'highlight MyMenu guifg=' . '<c-r>=g:menu_s ? g:menu_fg : g:menu_bg<cr>'<cr>
nn <buffer> <cr> :exe substitute(getline('.'),'.*COMMAND: ','','g')<cr>
norm <space>
echo 'Menu Loaded'
endf
au BufCreate *.menu call Menu()
If you add above code in your vimrc and then load awesome.menu, your command text will be hidden and you can use "space" to toggle its visibility and "enter" to execute it.
first thing you need to take care is, :exec doesn't support [range] , that is, you cannot :% exec !whatever
If I understood you right, you want to for each line in your example, pick part of the line, the text after COMMAND:, as external shell command, and execute it.
You can try this command:
exec '!'.substitute(getline('.'),'.*COMMAND: ','','g')
To apply it on all your lines, you can consider to use macro, it is pretty easy. Don't put sed in, it doesn't help much.
If you want to first execute the cmd, and then modify the line, remove COMMAND:.. part, you can chain a :s after the exec ...:
exec '!'.substitute(....)|s/COMMAND:.*//

Add space after colon zencoding-vim for .scss files

I am using the ZenCoding plugin for vim and I want it to expand CSS abbreviations by adding a space after every colon, which is not the current default behaviour for SCSS files.
I checked both Emmet's and zenconding-vim's documentation and I couldn't apply Emmet's custom property:
css.valueSeparator: ": "
to Vim. Which I tried by adding inside my .vimrc file.
let g:user_zen_settings = {
\ 'css' : {
\ 'valueSeparator' : ': '
\ }
\}
I am not sure whether I am missing something in ZenCoding's documentation or I am trying something that can't be done in ZenCoding.
I finally found the answer among zencoding-vim's issues:
https://github.com/mattn/zencoding-vim/issues/94
You must add this to to your .vimrc file:
let g:user_zen_settings = {
\ 'scss' : {
\ 'filters' : 'fc',
\ }
\}
Important! Don't miss the leading backslashes. They are required.

Resources