Comments (15)
verbose function /SearchParensPair
とやってもs:SearchParensPair()
が見つからないので、
h1mesukeさんの$VIMRUNTIMEと自分の環境の$VIMRUNTIMEが違ってるのかもしれません。
Vimのバージョンはいくつでしょうか?
あとできればs:SearchParensPair()
の定義を引用してくれますか?
from caw.vim.
あー、$VIMRUNTIME以前にこれを入れていたのでしたorz ↓
indent/python.vim - An alternative indentation script for python : vim online
http://www.vim.org/scripts/script.php?script_id=974
" Find backwards the closest open parenthesis/bracket/brace.
function! s:SearchParensPair()
let line = line('.')
let col = col('.')
" Skip strings and comments and don't look too far
let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" .
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
\ '"string\\|comment"'
" Search for parentheses
call cursor(line, col)
let parlnum = searchpair('(', '', ')', 'bW', skip)
let parcol = col('.')
" Search for brackets
call cursor(line, col)
let par2lnum = searchpair('\[', '', '\]', 'bW', skip)
let par2col = col('.')
" Search for braces
call cursor(line, col)
let par3lnum = searchpair('{', '', '}', 'bW', skip)
let par3col = col('.')
" Get the closest match
if par2lnum > parlnum || (par2lnum == parlnum && par2col > parcol)
let parlnum = par2lnum
let parcol = par2col
endif
if par3lnum > parlnum || (par3lnum == parlnum && par3col > parcol)
let parlnum = par3lnum
let parcol = par3col
endif
" Put the cursor on the match
if parlnum > 0
call cursor(parlnum, parcol)
endif
return parlnum
endfunction
from caw.vim.
あ、なるほど$VIMRUNTIMEではなかったんですね。どもです、確認してみます。
(コードが崩れてたので勝手ですが編集しちゃいました。
<code><pre>
を使うよりもmarkdownの引用形式を使って先頭にインデント使う形にしました)
from caw.vim.
問題が起こるのは Vim 7.2, 7.3 どちらでもです。
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Sep 28 2010 07:11:04) 適用済パッチ: 1-330 Compiled by buildd@ Huge 版 with GTK2-GNOME GUI. 機能の一覧 有効(+)/無効(-) +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra +perl +postscript +printer +profile +python +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white +tcl +terminfo +termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save システム vimrc: "$VIM/vimrc" ユーザ vimrc: "$HOME/.vimrc" ユーザ exrc: "$HOME/.exrc" システム gvimrc: "$VIM/gvimrc" ユーザ gvimrc: "$HOME/.gvimrc" システムメニュー: "$VIMRUNTIME/menu.vim" 省略時の $VIM: "/usr/share/vim" コンパイル: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -DORBIT2=1 -pthread -D_REENTRANT -I/usr/include/libgnomeui-2.0 -I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1 -I/usr/include/libgnome-2.0 -I/usr/include/libbonoboui-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gtk-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/gnome-vfs-2.0/include -I/usr/include/orbit-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/gail-1.0 -I/usr/include/freetype2 -I/usr/include/atk-1.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/libpng12 -Wall -g -O2 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.10/CORE -I/usr/include/python2.6 -pthread -I/usr/include/tcl8.4 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1 -I/usr/lib/ruby/1.8/i686-linux リンク: gcc -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,--as-needed -o vim -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpng12 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lgnomeui-2 -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lpng12 -lgconf-2 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lXt -lncurses -lselinux -lacl -lgpm -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.10/CORE -lperl -L/usr/lib/python2.6/config -lpython2.6 -lutil -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib -ltcl8.4 -lieee -lruby1.8 -lrt -lm
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 4 2011 12:03:39) Included patches: 1-293 Compiled by himesuke@lachesis Huge version without GUI. Features included (+) or not (-): +arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg +path_extra -perl +persistent_undo +postscript +printer +profile -python -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/home/himesuke/local/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -D_FORTIFY_SOURCE=1 Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lm -lncurses -lnsl
from caw.vim.
情報が小出しになってしまってすいません。
.vim/indent に python.vim を放り込んだのをすっかり失念しておりました。
確か、標準のものだとインデントが思った通りにならなかっため導入したのだったと思います。
from caw.vim.
了解しました。
とりあえずエラーが起きた場合は組み込みのcindent()
, lispindent()
, indent()
などを使ってインデント数を取得するようにしました。
これで正常にindent数は取れてるでしょうか?
本当ならindent/python.vim
の方で対処してもらう方がいいので、
indent数が取れていないようならそっちの対処も検討します。(正直あまりモチベーションは湧かないのでできるかどうかは保証できません。すみません...)
その場合どのようなコードを編集してどのキーを押したらこういうindentを入れてほしい、など求めてるケースも示してもらうとわかりやすいです。
いろいろと聞いてしまってすみません。
from caw.vim.
エラーは出なくなりましたが # が行頭に入ります。
if のある行にカーソルがある状態で gco すると
def main():
opts, args, argc = parse_args()
if argc < 1:
parser.error("Search pattern not given.")
elif argc == 1:
pattern = args[0]
else:
こうなります↓ (I はカーソルを表しています)
def main():
opts, args, argc = parse_args()
if argc < 1:
# I
parser.error("Search pattern not given.")
elif argc == 1:
pattern = args[0]
else:
期待しているのはこう↓
def main():
opts, args, argc = parse_args()
if argc < 1:
# I
parser.error("Search pattern not given.")
elif argc == 1:
pattern = args[0]
else:
from caw.vim.
うーむpython.vimインストールしてみましたが、再現しないですね。
冒頭の報告で「ある地点からこのエラーが出るようになり」とあるので使っててpython.vimのエラーが出たらそのようなインデントになってしまうんだと思うんですが、エラーの再現方法が分からないので今のところちょっと対処のしようがないです。
from caw.vim.
バッファの後ろの方でも再現しませんか?
こちらの環境だと手元にある Pythonスクリプトでことごとく同じ症状なんですよね。ううむ、何が違うのだろうか。
上から順番に試していくと、この行からおかしくなってるな、という箇所を特定できるのですが、
今のところ条件がよくわかりません。
何かわかったら報告します。
from caw.vim.
上のスクリプトを保存して全行で試しましたが、
こちらではgco
, gcO
共に @h1mesuke さんが示した誤動作例のような挙動はしないです。
(うーんcatchで何かメッセージ吐いた方がいいだろうか...
でもエラーが出たらそれ以後ダメとなると、エラーが出た後えんえんとメッセージが吐かれてしまってうっとうしいだろうし...)
何かわかったら報告します。
よろしくお願いします。
from caw.vim.
上のスクリプトを保存して全行で試しましたが、
ああ、あれは抜粋ですよ。抜粋部分の上に100行くらいあって、その途中からおかしくなります。
(バッファの先頭から数十行くらいは大丈夫)
なので、数百行くらいの規模のスクリプトであればバッファの後ろの方で再現しませんか、という意味でした。
from caw.vim.
エラーの原因がわかりました。
というか、エラーメッセージの通りで、
" Skip strings and comments and don't look too far
let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" .
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
\ '"string\\|comment"'
この dummy が未定義だってことですね。
ここは searchpair()関数の第5引数に渡す式を作っている部分で、searchpair() の説明を読む限りでは
この dummy は non-zero な何かでなければならないのですが……
多分作者が変数の初期化を忘れたものと思われます。
以下のパッチで、エラーは出なくなりました。
--- old_python.vim 2011-09-09 16:01:28.428454002 +0900
+++ python.vim 2011-09-09 15:59:13.232454001 +0900
@@ -24,6 +24,7 @@
let col = col('.')
" Skip strings and comments and don't look too far
+ let dummy = 1
let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" .
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
\ '"string\\|comment"'
これまでインデント自体は問題なくできていたのが謎。Vim が内部的に呼び出す分には顕在化しないのだろうか?
報告もされず放置されてきたようだし。
このパッチをメンテナである Eric Mc Sween氏に送ってみようと思います。
が、どう説明するのがいいのやら……
from caw.vim.
このパッチをメンテナである Eric Mc Sween氏に送ってみようと思います。
が、どう説明するのがいいのやら……
(スクリプトを引用して)どういうステップを踏むとエラーが起きるのか、
そしてこのパッチを当てたら直ったよ、というようなメールでいいと思います。
よろしくお願いします!
from caw.vim.
問題の indent/python.vim のメンテナである Eric Mc Sween氏にメールを送ってみましたが
mailer-daemonさんから Delivery to the following recipient failed permanently: と返ってきました。
最終更新が 2005年ということもあるし、もうメンテされてない模様。
現実的な解としては他の indent/python.vim 探して使え、ということだと思います。
caw.vim の問題ではないので、この issue はクローズします。
from caw.vim.
ふむふむ、了解しました。
from caw.vim.
Related Issues (20)
- JSON "comments"
- Toggle does not work when using nvim-tree-sitter
- Comments in vue file inconsistent after first template element HOT 1
- Can't comment blank line with default configuration g:caw_hatpos_skip_blank_line = 0
- Doesn't comment current line when lazy loading it and set remembering last cursor location
- how can i use it? HOT 1
- toggle caw error HOT 2
- Join undo history when inserting comment
- Join repeat history when inserting comment
- weird case with context filetype
- fileType=dosbatchの時、トグルとコメント解除が動作しない
- "Press Enter or type command to continue" prompt at uncomment multi lines
- Use `#` instead of `"` in Vim9 script HOT 2
- Incorrect comments for 'typesriptreact'
- uncomment work unexpectly when single line has multi warp comment
- E117: Unknown function: caw#keymapping_stub
- [feature] b:caw_dollarpos_sp_left HOT 1
- caw.vim can't works well with treesitter HOT 1
- Error on uncomment HOT 1
- caw.vim can't works well in markdown file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caw.vim.