Add space after colon zencoding-vim for .scss files - vim

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.

Related

How do I display icons in 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

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.

Vim -- Double Inclusion Guard

Id'd like to be able to repeatedly insource my ~/.vimrc.local file (I'm using the sp13-vim distro), but I get error messages in the part of that file when I have Bundle/UnBundle statements. How can I prevent that part to be double executed.
That is, how do I write the following in Vimscript?:
if guard_global_not_defined
define_guard_global
do stuff
endif
The canonical structure is
if !exists('g:didBundle')
let g:didBundle = 1
Bundle ...
...
endif
As bundles are globally scoped, the g: prefix makes it a global guard. You can do the same with other scopes (e.g. b: for buffer-local stuff).
The local_vimrc files I'm using have the following kind of include guards: https://github.com/LucHermitte/Rasende/blob/master/_vimrc_local.vim
The latest templates I'm using are a little bit different (they are meant to support projects having global definitions that need to be set before the local settings (like a project name, where to find sources, build configurations and their related build directories), and local tunings).
When expanded, the result look like this (you certainly don't need everything):
let s:k_version = 42
" Always loaded {{{1
" Buffer-local Definitions {{{1
" Avoid local reinclusion {{{2
if &cp || (exists("b:loaded_tests_lh_vimrc_local")
\ && (b:loaded_tests_lh_vimrc_local >= s:k_version)
\ && !exists('g:force_reload_tests_lh_vimrc_local'))
finish
endif
let b:loaded_tests_lh_vimrc_local = s:k_version
let s:cpo_save=&cpo
set cpo&vim
" ======================[ Project config {{{2
if ! (exists("g:loaded_tests_lh_vimrc_local")
\ && (g:loaded_tests_lh_vimrc_local >= s:k_version)
\ && !exists('g:force_reload_tests_lh_vimrc_local'))
source <sfile>:p:h/_vimrc_local_global_defs.vim
endif
" ======================[ Local settings {{{2
.... <- here go your local settings
"--------------------------------------------------------------------
" Global Definitions {{{1
" Avoid global reinclusion {{{2
if &cp || (exists("g:loaded_tests_lh_vimrc_local")
\ && (g:loaded_tests_lh_vimrc_local >= s:k_version)
\ && !exists('g:force_reload_tests_lh_vimrc_local'))
finish
endif
let g:loaded_tests_lh_vimrc_local = s:k_version
" ======================[ Functions {{{2
.... <- here go some more global stuff like functions
" }}}1
"--------------------------------------------------------------------
let &cpo=s:cpo_save
"====================================================================
" vim600: set fdm=marker:
PS: I found quite odd that you have a local_vimrc at your very $HOME directory. They are meant to be at the root of project trees. And moreover they shall not be loaded by a plugin manager but by a local-vimrc plugin.

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:.*//

Resources