Code Monkey home page Code Monkey logo

unite-outline's Introduction

unite-outline

Introduction

unite-outline is a unite.vim's source which provides your Vim's buffer with the outline view. It parses the current buffer's content and extracts headings from the buffer. And then it shows the list of the headings using unite.vim's interface. When you select a heading from the list, you can jump to the corresponding location in the buffer.

The methods for extracting headings can be implemented for each individual filetypes. You can customize them as you like with Vim script and can also create new ones for unsupported filetypes.

Install

Install the distributed files into your Vim script directory which is usually $HOME/.vim, or $HOME/vimfiles on Windows.

You can show the heading list of the current buffer with ":Unite outline" command if you succeeded the installation (and unite-outline supports the filetype of the buffer).

Usage

To show the heading list of the current buffer, execute |:Unite| command with "outline" as a source parameter.

:Unite outline

unite-outline parses the current buffer's content and extracts headings from the buffer. And then it shows the list of the headings with unite.vim's interface. When you select a heading from the list, you can jump to the corresponding location of the buffer.

See :help unite-outline for more details.

Screenshots

See unite-outline's wiki.

unite-outline's People

Contributors

h1mesuke avatar hamaco avatar kenchan avatar thinca avatar tyru avatar ujihisa avatar ukstudio avatar zhaocai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unite-outline's Issues

Asynchronous heading extraction.

現在、unite-outline の見出し抽出は非同期ではないため、見出しの抽出中はユーザーは他の操作が行えない。
大抵の場合、見出しの抽出は瞬時に終わるため、これが問題となる局面は少ないが、

以下の場合に、抽出時の待ち時間が大きくなり、無視できなくなることがある。

  • 見出し抽出に外部プログラムを使う場合
    • C/C++/Java における ctags の使用がこれにあたる
    • Windows では特にプロセスの起動が遅く、
      200行程度のバッファからの見出し抽出に1秒以上を要するとの報告があった
  • ファイルが大きい場合
    • 数万行とかいう規模になってくるとさすがに厳しいか
  • マシンが貧弱な場合

このような場合でも、ユーザーをブロックすることなく見出しの抽出を行えるよう、
見出しの抽出を非同期に行えるようにすべきである。

案1: vimproc を使う

一番有力な案。というか、これ以外にどういうやり方があるものかまったく思いつかないw

もし、ユーザーが vimproc をインストールしており、かつ、オプションで非同期な抽出を許可する設定をしていれば、vimproc を使って非同期に見出しを抽出する。この辺の設定は filetype_option としてファイルタイプごとに持たせられればいいかな。非同期な見出し抽出が必要になるファイルタイプって限られると思うので。

抽出結果はファイルを介して受け渡すのが無難か?
とするならば、常時 FileCache から読むような感じになるか。もはやキャッシュではないなあ。

vimproc について理解を深める必要がある。ソースを読んで仕組みを把握しよう。neocomplcache がまさにこういった vimproc の使い方をしているとのことなので、参考にできるだろう。

問題点

  • vimproc は導入の敷居が高い
    • ビルドが必要、Windows だと特にめんどい

案2: シェルにバックグラウンド実行させる

結局 system() 経由でシェルを叩くんだから、シェルにバックグラウンド実行させるという方法もある。
vimproc は導入の敷居が高いので、なしでもいけるらそっちの方がいい。

問題点

  • シェルによってバックグラウンド実行の指定方法が異なる
    • & だったり &! だったり
    • cmd.exe もこれまた違う

Foldmarker Support & Argument to Force Outline Certain Filetype

I just found this very handy tool. Great Job!

One thing I notice that is missing is fold marker support! It should be easy to parse based on &fmr. Will you consider to add it?

And how to force outline to use filetype other than current &ft. For example, I have a document containing some markdown style headers but it is not a strict markdown file. Unite outline:markdown does not work.

Function that returns the heading closest to the cursor.

statusline にカーソル行が所属する見出しの word を表示したりといったことに使える。
見出しのリストはバッファローカル変数に入っており、個々の見出しは対応する行番号を持っているので、for でまわしてカーソル行の行番号と比較していけば、カーソル位置に一番近い見出しが見つかる。

hlsearch on narrowing

絞り込み時のマッチ箇所ハイライト、unite-line でやってるやつ。できたら unite-outline でもやりたい。
ただ、見出し自体のハイライトを既にやっているので、実現は難しいかも。

parse in tex file

\section{hoge} % comment

という入力に対して、 "}\s*$" で閉じかっこの判定をしているため、正しく処理できていません。

Undefined variable: g:unite_data_directory

概要

素晴らしいツールを作っていただき,ありがとうございます.
自分の環境で unite-outline を実行すると,つぎのようなエラーが出ます.
以前は使えていたのですが,いつのまにやらエラーが出るようになりました.
原因について,調査いただけますでしょうか?

Error detected while processing ~/.vim/bundle/unite-outline/autoload/unite/sources/outline.vim:
line   52:
E121: Undefined variable: g:unite_data_directory
E15: Invalid expression: g:unite_data_directory . '/outline'

同じような問題が発生している方もいる模様です.

動作環境

vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 18 2014 09:46:58)
MacOS X (unix) version
Included patches: 1-335
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         -gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.9 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa    -framework Python   -lruby.2.0.0 -lobjc

バッファと見出し一覧のカーソル行の同期

見出し一覧を表示した時、カーソル位置に最も近い見出しを自動的にカーソル行にする機能
-no-quit で使った場合はリアルタイムにカーソル行が同期されるようにしたい。

が、場合によっては前回の位置にカーソル行が残っていて欲しい場合もあるだろうから、
オプション変数で ON/OFF するようにするか。

ちなみに、Tagbar はこれができる。

Control whitespace squeezing.

ファイルタイプによっては連続する空白の圧縮が不都合な場合がある。
outline info の属性によって、この機能の ON/OFF を制御できるといいかも知れない。

省略時は ON で、既存の outline info は変更の必要なしとすべき。

問題は属性の名前

normalize_heading_word: 0
squeeze_whitespaces: 0

あたり?

Switching search-key word <-> abbr on narrowing.

絞り込み時に仮引数名などにマッチしないように word から仮引数名などは除外されているが、
たまに表示されている見出しそのものに対してマッチさせたくなる時がある。

パターンの前に ! を付けることでマッチングの意味を逆転させられるのと同じような仕組みで
マッチ対象として abbr の方を選択できるようにできないか。ある記号をパターンに前置することでそうなるとか。

Deprecate need_blank_between()

この関数はインターフェースもひどい上に、heading でなく unite の candidate(outline info から見えるべきでない)が渡されてくるなど、どう考えても本体内部に隠蔽されているべき部分。これが outline info の仕様として露出しているのはよくないのでなくす。

で、このような関数を定義することなく formatter の振る舞い(空行をどこに入れるか)を制御できる仕組み、仕様を考えるべき。

outline info に formatting_rules のような属性を設定できるようにし、その値によって foramtter の振る舞いを制御するような方法が考えられる。

Better testing environment and automate tests as possible.

現在のやり方

Vim script でファイルを順番に開いていって :Unite outline を実行させ、結果を目視で確認、
OK かどうかをプロンプトにて答えていくというもの。

問題点

ユニットテストに相当するレイヤーのテストがない。
内部のモジュール関数やスクリプトローカル関数が意図した通りに動いているか、きちんと検証できていない。

目視による確認が前提のテストなので自動化し辛い。
ファイルタイプの数も増えてきてそろそろ限界。テストするのも億劫になって悪循環。

対応

ユニットテストに相当するレイヤーのテストを増やす。
unittest.vim を使う。必要な機能がいろいろ足りてないので追加して対応する。

目視による確認事項を最小限におさえ、大半を自動化、テストの負担を下げる。

Outline for Java/C/C++ files doesn't work

Hi guys,

I'm trying to setup my vim to use Unite to replace a bunch of plugins I have but I can't make unite-outline work with Java / C / C++ code. I do have crags installed and working here (tagbar plugin works like a charm) but when I invoke unite outline with:

:Unite outline:!

I get a blank list.

Am I suppose to configure something to make outline uses ctags in this case?

Python でクラスのメソッドがアウトライン表示されない場合がある

こんにちは。

Python で https://gist.github.com/1533093 のようなクラスを定義した際に、
__init__() 内に docstring があった場合と無かった場合で挙動が異なるようです。

__init__() 内に docstring が無い場合意図通り、全てのメソッドが表示されます。

Sources: outline
> 
-   Sample : class
-     __init__ (self)
-     none_docstring (self)
-     docstring (self)
-     foo (self)

__init__() 内に docstring があった場合、メソッドが一部だけしか列挙されません。

Sources: outline
> 
-   Sample : class
-     __init__ (self)
-     foo (self)

No matching autocommands error

Hi

I am getting the following error when i do

:unite-outline in a .py file. Can anyone please help what is the issue?
function 93_call_unite_empty..unite#start..unite#start#standard..unite#candidates#_recache..156_recache_candidates_loop..156_get_source_candidates..126_Source_gather_candidates..126_get_candidates..126_extract_headings, line 68
Vim(unlet):E716: Key not present in Dictionary: lines
No matching autocommands
No matching autocommands

Thanks
Abi

Default matcher

Hi,

I use

call unite#filters#matcher_default#use(['matcher_fuzzy'])

to set default matcher, but unite-outline does not use the default matcher. This is easily worked around with

call unite#custom#source('outline', 'matchers', 'matcher_fuzzy')

I would expect that matcher_default should be used?

Improve JavaScript's outline info.

現在、JavaScript の見出し抽出は正規表現マッチ+create_heading() でやっているが、限界

実行時にならないとわからない情報が多いため、見出し間の親子関係が把握しづらく、ツリーが作りにくい。
また、OOP の流儀(書き方)もいろいろあるので、オブジェクトの役割(見出しの type)も判別しにくく、
適切なハイライトを設定することも難しい。

案1: jsctags を呼び出す

C/C++/Java で ctags を使うのと同様の発想。以下のエントリに触発されてのもの↓

Awesome vim support for javascript with jsctags and taglist-plus | discontinuously.com
http://discontinuously.com/2011/03/vim-support-javascript-taglist-plus/

Miscellany: Introducing jsctags
http://pcwalton.blogspot.com/2010/05/introducing-jsctags.html

taglist-plus はこれでうまくやっているらしい。

問題点

  • jsctags の導入手順が面倒
    • node.js もいるしー
  • jsctags がそもそも不安定というか、エラーで落ちるw

jsctags ほど導入に手間のかかるものを required とすることはできないと思うので、あれば使う、という感じになると思う。
よって、結局現在の outline info をなくせるわけではない。こっちはこっちで頑張る必要あり。

導入の手間より問題なのは、jsctags自体がスクリプトの評価中に落ちてしまうことだ。
自分が試したバージョンでは jQuery を食わせたら落ちてしまった。これではちょっと話にならない。今なら大丈夫か?

jsctags自体の開発の動向をしばらく見守る必要がある。

案2: Vim script で頑張る

jsctags を使うにしても、optional という扱いになると思うので、結局こっちも必要

幸いなことに関数の定義には予約語 function が使われる分、C/C++/Java のように定義と呼び出しが見分けられないみたいなことはないだけマシか。後は、コードが適切にインデントされているという前提であれば、なんとか……

問題はクラスとメソッド、という親子の関係をどう認識して、論理的に正しい見出しのツリーを作ることができるか。
JavaScript の OOP は書き方もいろいろあるので、そこをどうするかが一番難しい気がする。

Extract outline from file/files...

Correct me if I am wrong... unite-outline seems only work with current buffer.

Any way to allow heading extracting from arbitrary file? or even from multiple files...

an error with compound filetype

compound filetype(*1) でたとえばruby.rspecなfiletypeのbufferで:Unite outlineすると下記のようなエラーになりました。

function <SNR>49_call_unite_empty..unite#start..unite#force_redraw..<SN
R>28_redraw..<SNR>28_recache_candidates..91..unite#sources#outline#get_
outline_info, line 21
Vim(let):E121: Undefined variable: unite#sources#outline#ruby

(はじめ下記が牡蠣と変換されてしまいました。こんな寒い日は牡蠣の入った鍋などを食べたいですね。こちら外気-8Cでございます。)

*1 http://whileimautomaton.net/2008/09/07213145

unite-outlineの引数に、任意のファイル名を取れるようにする

http://twitter.com/hrsh7th さんが、unite-outilneを使って補完を実現しようとしているみたいで、
それは面白いと思ったので要望。
現在の仕様だと、(おそらく)カレントバッファしかキャッシュ・アウトライン表示できない仕様だと思うのですが、
これを引数で可変にできるようしてほしいです。
引数に与えられたファイルをキャッシュして表示します。与えられなければ、これまでどおりの挙動。
実装は簡単でないかもしれません。

Not working for ctags-dependent languages

I have Exuberant Ctags installed, but whenever I invoke :Unite outline on a C file, I only get the following message:

[unite-outline] Sorry, C is not supported.

Exuberant Ctags is located in /usr/local/bin, it is in the PATH. If I run :!ctags --version from vim, I get the following:

Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jan 16 2012, 11:29:29
  Addresses: <[email protected]>, http://ctags.sourceforge.net
  Optional compiled features: +wildcards, +regex

This used to work until I updated unite-outline in about January. I could not find which commit caused the problem, because older unite-outline versions seem to be incompatible with the current unite plugin...

既存の outline info を継承する仕組み

仕組みなどという大げさなものでなくても、イディオムのようなものでいいので、やり方を確立しておきたい。

例えば Ruby を例にとれば

  • Ruby の outline info を元に RSpec用、Rake用と各種 DSL用の outline info を作りたい
    • その際、Ruby の outline info に対する差分だけ設定できれば楽
  • Ruby の outline info をいじるとそれを継承した outline info にも効果が波及

みたいなことがやりたい。

get_default_outline_info() を使えば、継承元の辞書をもってくることは簡単。
それをコピーして、差分を設定すればよさげ。

見出しパターンの差分をどう混ぜ込むかが問題
文字列としてハードコードしてしまうとサブパターンの追加がやりにくくなるので、s:heading_patterns のような変数にリストとして持たせて getter を用意し、リストを join() することでパターン文字列を作るみたいにしておけば、継承した側でパターンに差分を混ぜ込むことができる。

join() するので設定できるパターンに制約はできてしまうが、それでなんとかなるんじゃないか。

絞り込み時に小見出しも残すマッチ方法

たまに絞り込み結果に小見出しも残って欲しい時がある。
絞り込み文字列(input) の末尾になんらかの記号をおくことでそれを指示する、とかはどうだろうか。

見出しの更新を実際に表示する時まで遅延する

write と hold 以外の auto_update_event の選択肢として、見出しの更新を実際に表字する時まで遅延する show も欲しい。

write もどちらかというと、-no-quit で見出し一覧が常時表示されている状態を見越している。
この場合、:w のタイミングで見出し一覧が更新されのはそんなにおかしくない。

一方、見出し一覧が常時表示されているのでないなら、見出しの更新タイミングは実際にそれを表示するときまで遅延できる。
その場合、見出しを表示する時に待ち時間が生じるが、外部プロセスを呼び出すなどの理由で見出しの抽出にそれなりの時間がかかってしまうファイルタイプでは、見出しの更新を最低限に抑えられるし :w で毎回待たされることはなくなるので、全体として使用時のストレスは軽減できるのでは。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.