Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-detect comments #159

Closed
bestouff opened this issue Mar 6, 2020 · 7 comments
Closed

Auto-detect comments #159

bestouff opened this issue Mar 6, 2020 · 7 comments

Comments

@bestouff
Copy link

bestouff commented Mar 6, 2020

Hi,

I have a CSV file like this:

# comment 1
# comment 2
col1;col2;col3
data1;data2;data3
data1;data2;data3

Would it be possible to have the comment somehow auto-detected ? Or at least a command to inform the plugin that # is a start-of-comment ?

@chrisbra
Copy link
Owner

chrisbra commented Mar 9, 2020

How should the plugin detect comments automatically? It uses the &commentstring option currently to do so. I am not sure, what better ways it could use.

@bestouff
Copy link
Author

bestouff commented Mar 9, 2020

I thought maybe if all lines that don't contain the column separator start with the same character, this is the start-of-comment ?

Anyway I tried :set commentstring="#%s" but that didn't seem to change anything - at least the syntax highlighting didn't change. So I wasn't sure if comments are handled by csv.vim.

@chrisbra
Copy link
Owner

chrisbra commented Mar 9, 2020

Anyway I tried :set commentstring="#%s" but that didn't seem to change anything - at least the syntax highlighting didn't change. So I wasn't sure if comments are handled by csv.vim.

You need to re-init the plugin. Run CSVInit after changing the comment character.

@bestouff
Copy link
Author

bestouff commented Mar 9, 2020

Well, this results in:

Error detected while processing function <SNR>249_CheckSaneSearchPattern:
line   37:
E684: list index out of range: 0

and then when pressing a cursor key:

Error detected while processing function csv#MoveCol[6]..csv#MaxColumns:
line   12:
E684: list index out of range: 0
E116: Invalid arguments for function escape(b:csv_cmt[0], '\\')
line   13:
E121: Undefined variable: pat
Error detected while processing function csv#MoveCol[9]..CSVWidth[21]..csv#CalculateColumnWidth[11]..csv#MaxColumns:
line   12:
E684: list index out of range: 0
E116: Invalid arguments for function escape(b:csv_cmt[0], '\\')
Error detected while processing function csv#MoveCol[9]..CSVWidth:
line   21:
E171: Missing :endif
Error detected while processing function csv#MoveCol:
line    9:
E171: Missing :endif

@chrisbra
Copy link
Owner

chrisbra commented Mar 9, 2020 via email

@chrisbra
Copy link
Owner

:set commentstring="#%s"

That obviously needs to be :set commentstring=#%s, note the missing ", which Vim sees as comments and hence the errors in the csv#MaxColumns functions.

Error detected while processing function 249_CheckSaneSearchPattern:
line 37:
E684: list index out of range: 0

That looks wrong. Please show the output of the following commands:

 :redir => a |sil filetype | redir end
 :echo a

Also, what Vim version is this?

chrisbra added a commit that referenced this issue Mar 10, 2020
@bestouff
Copy link
Author

filetype detection:ON plugin:ON indent:ON

I'm using spacevim with

VIM - Vi IMproved 8.1 (2018 May 18, compilé Mar 03 2020 16:41:00)
Rustines incluses : 1-2269
Modifié par team+vim@tracker.debian.org
Compilé par team+vim@tracker.debian.org
Énorme version sans interface graphique.
  Fonctionnalités incluses (+) ou non (-) :
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     -perl              -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           -python            +visual
+cmdline_info      +libcall           -python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          -ruby              +wildmenu
+cursorbind        -lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      +sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        -xsmp
+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
         fichier vimrc système : "$VIM/vimrc"
     fichier vimrc utilisateur : "$HOME/.vimrc"
 2me fichier vimrc utilisateur : "~/.vim/vimrc"
      fichier exrc utilisateur : "$HOME/.exrc"
 fichier de valeurs par défaut : "$VIMRUNTIME/defaults.vim"
               $VIM par défaut : "/usr/share/vim"
Compilation : gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-LZqrFQ/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Édition de liens : gcc   -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux -lcanberra -lacl -lattr -lgpm -ldl           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants