MacVim NERDCommenter, how to specify alternative delimiters - vim

When I'm editing html and xhtml files in MacVim, sometimes I need to comment embedded css styles, so when I try to switch to the alternative set of delimiters ( ca ), the plugin warns me with:
NERDCommenter:cannot use alternative delimiters, none are specified
My question is:
how can I specify these alternative delimiters?

These can be specified in the config variable g:NERDCustomDelimiters (before the plugin is sourced, e.g. in your ~/.vimrc):
:let g:NERDCustomDelimiters = {
\ 'html': { 'left': '<!-- ', 'right': '-->', 'leftAlt': '/*', 'rightAlt': '*/' }
\ }

Added these lines to my .vimrc :
let g:NERDCustomDelimiters = {
\ 'html': { 'left': '<!-- ', 'right': '-->', 'leftAlt': '/*','rightAlt': '*/' },
\ 'xhtml': { 'left': '<!-- ', 'right': '-->', 'leftAlt': '/*','rightAlt': '*/'},
\}
let NERD_html_alt_style=1
NOTE: Don't forget about the commas after the curly braces!! :)

Related

how to enable emmet in vim for ejs file

I wanna use emmet-vim on ejs files, my .vimrc config is
let g:user_emmet_install_global = 0
autocmd FileType html,css,ejs EmmetInstall
" redefine trigger key
let g:user_emmet_leader_key=','
let g:user_emmet_settings = {
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'c',
\ },
\ 'xml' : {
\ 'extends' : 'html',
\ },
\ 'haml' : {
\ 'extends' : 'html',
\ },
\ 'ejs' : {
\ 'extends' : 'html',
\ }}
yet it couldn't work, can anyone help?
P.S. my emmet-vim functions normally on html and css files
Maybe you can try it in this way with web-api
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.snippets_custom.json')), "\n"))
Reference: emment-vim

Python - PEP8 hanging indent error message

For the following code I am getting the below error:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['bucket']['name'],
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['object']['key']
I have tried a few options including the below - but it is not working:
config = {
'bucket': json.loads(
record['body']
)
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
I have also tried + \ at the end of the line but does not work also
To conform with PEP8, the below worked for this scenario:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
Try this, it should be either this format
config = {
'bucket': json.loads(record['body'])['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])['Records'][0]['s3']['object']['key']
}
or in this,
config = {
'bucket': json.loads(record['body']) \
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body']) \
['Records'][0]['s3']['object']['key']
}
For more information, please check What is PEP8's E128: continuation line under-indented for visual indent? question.

how to configuration vim-easytags for javascript

I want to use vim-easytags for javascript, so that it can use jsctags to generate tags each time I save my code. From the documentation of vim-easytags, I notice it supports javascript tags and jsctags. But how to set the configuration struggled me. Can anyone help me fix my .vimrc?
let g:easytags_python_enabled=1
let g:easytags_events = ['BufWritePost']
let b:easytags_auto_highlight = 1
let g:easytags_async=1
let g:easytags_by_filetype=1
let g:easytags_languages = {
\ 'javascript': {
\ 'cmd': 'jsctags',
\ 'args': ['-f'],
\ 'fileoutput_opt': '-f',
\ 'stdout_opt': '-f-',
\ 'recurse_flag': '-R'
\ }
\}
This seems to do it for me:
let g:easytags_languages = {
\ 'javascript': {
\ 'cmd': 'jsctags',
\ 'recurse_flag': ''
\ }
\}

ANTLR4 extraneous input

I have a problem with my ANTLR4. I'm trying to print AST from python 3 code but there are some errors and I don't know how to fix them.
I wrote simple code for test:
a=(1,2,3)
print(a)
I ran the program but this errors appeared:
line 1:1 extraneous input '=' expecting {<EOF>, '.', '*', '(', '**', '[', '|', '^', '&', '<<', '>>', '+', '-', '/', '%', '//', '#'}
line 2:0 extraneous input '\n' expecting {<EOF>, '.', '*', '(', '**', '[', '|', '^', '&', '<<', '>>', '+', '-', '/', '%', '//', '#'}
line 3:0 extraneous input '\n' expecting {<EOF>, '.', '*', '(', '**', '[', '|', '^', '&', '<<', '>>', '+', '-', '/', '%', '//', '#'}
My main class :
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;
import org.antlr.v4.*;
public class Main {
public static void main(String[] args) {
try {
ANTLRInputStream input = new ANTLRFileStream("/home/grzegorz/Desktop/Python3/input.txt");
Python3Lexer lexer = new Python3Lexer(input);
CommonTokenStream token = new CommonTokenStream(lexer);
Python3Parser parser = new Python3Parser(token);
ParseTree parseTree = parser.expr();
System.out.println(parseTree.toStringTree(parser));
}catch (Exception ex){
ex.printStackTrace();
}
}
}
I have the grammar from this site:
https://github.com/antlr/grammars-v4/tree/master/python3
Explanation
Your input file consists of two statements and you are parsing the file as if it was an expression (with line ParseTree parseTree = parser.expr();; rule expr from Python 3 grammar).
This also exaplains the first error: an identificator a is accepted as a part of expression but = sign is not. That's because = is a part of assignment statement.
Solution
Parse the input using another grammar rule for example file_input rule which will accept many statements. Change the abovementioned line to ParseTree parseTree = parser.file_input();.

Displaying ► character in Vim terminal lightline status bar

I am working on SUSE Linux Enterprise Desktop 11 (x86_64) and I am using Vim in terminal as my editor. I have recently installed a plugin called lightline from https://github.com/itchyny/lightline.vim. The plugin uses special characters to make the status line look like this:
The > part of the bar is actually ► character coloured like the square next to it. The problem is that the bar, in my case, looks like this:
The ► character is not displayed properly, although the encoding is set to UTF-8 and all the required fonts are installed on the system (fonts for powerline). In this case the font set on terminal is Liberation Mono for Powerline.
Lightline settings in my vimrc:
set encoding=utf-8
scriptencoding utf-8
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'separator': {'left': "\u25B6", 'right': ''},
\ 'subseparator': { 'left': '', 'right': ''}
\ }
I also tried copying the ► character like this
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'separator': {'left': "►", 'right': ''},
\ 'subseparator': { 'left': '', 'right': ''}
\ }
But it manifests in the same way.
Furthermore, there is a problem with ^ characters wherever there is supposed to be whitespace.
Is there any solution for this?
Following is my my_configs.vim for lightline, it works perfectly in my Fedora 26 system.
let g:lightline = {
\ 'colorscheme': 'wombat',
\ }
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ ['mode', 'paste'],
\ ['fugitive', 'readonly', 'filename', 'modified'] ],
\ 'right': [ [ 'lineinfo' ], ['percent'] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"\ue0a2":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"\ue0a0":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ } "" This is comment: I fotgot this line in my last post, just added
Sorry for my mistake, I just fixed this config.
If you installed hack font from https://github.com/chrissimpkins/Hack/releases
and install powerline-fonts by command "sudo dnf install powerline-fonts" in Fedora 26 system, you probably want to add the following configs to your
/etc/fonts/local.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>Hack</family>
<prefer>
<family>PowerlineSymbols</family>
</prefer>
</alias>
</fontconfig>
The problem was explained in this thread stackoverflow.com/questions/7223309/. It says that if the stl and stlnc have the same values, they will be replaced with ^^^. It works when you put * for stlnc and whitespace for stl.

Resources