├── .gitignore
├── doc
├── vim-stardict_bash.png
├── vim-stardict_vim.png
├── vim-stardict_split.png
├── vim-stardict_vsplit.png
└── vim-stardict.txt
├── TODO
├── CONTRIBUTING.md
├── LICENSE.txt
├── syntax
└── stardict.vim
├── plugin
└── stardict.vim
├── bindings
├── bash
│ └── stardict.sh
└── zsh
│ └── stardict.zsh
├── autoload
└── stardict.vim
├── README.md
└── python
└── stardict.py
/.gitignore:
--------------------------------------------------------------------------------
1 | /doc/tags
2 | /python/__pycache__/
3 | /python/.ropeproject/
4 | *.pyc
5 |
--------------------------------------------------------------------------------
/doc/vim-stardict_bash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phongvcao/vim-stardict/HEAD/doc/vim-stardict_bash.png
--------------------------------------------------------------------------------
/doc/vim-stardict_vim.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phongvcao/vim-stardict/HEAD/doc/vim-stardict_vim.png
--------------------------------------------------------------------------------
/doc/vim-stardict_split.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phongvcao/vim-stardict/HEAD/doc/vim-stardict_split.png
--------------------------------------------------------------------------------
/doc/vim-stardict_vsplit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phongvcao/vim-stardict/HEAD/doc/vim-stardict_vsplit.png
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | - Add support for Windows
2 | - Implement word lookup in Visual Mode (look up the selected text)
3 | - Once opened under :StarDictCursor mode, whenever the mouse move to a new word,
4 | vim-stardict automatically looks up for that word (let g:stardict_lookup_on_mousemove)
5 |
6 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing to vim-stardict
2 | ============================
3 |
4 | * Please create your Pull Requests on the official repository at
5 | [phongvcao/vim-stardict](https://github.com/phongvcao/vim-stardict)
6 |
7 | * Please DO NOT create your Pull Requests on the mirror repository
8 | [vim-scripts/vim-stardict](https://github.com/vim-scripts/vim-stardict) (I
9 | don't have "write access" to this mirror repository, so I cannot merge your
10 | Pull Request even if it contains some damn good ideas)
11 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (C) 2015 Phong V. Cao
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/syntax/stardict.vim:
--------------------------------------------------------------------------------
1 | "=============================================================================
2 | " FILE: autoload/stardict.vim
3 | " AUTHOR: Phong V. Cao
4 | " License: MIT license {{{
5 | " Permission is hereby granted, free of charge, to any person obtaining
6 | " a copy of this software and associated documentation files (the
7 | " "Software"), to deal in the Software without restriction, including
8 | " without limitation the rights to use, copy, modify, merge, publish,
9 | " distribute, sublicense, and/or sell copies of the Software, and to
10 | " permit persons to whom the Software is furnished to do so, subject to
11 | " the following conditions:
12 | "
13 | " The above copyright notice and this permission notice shall be included
14 | " in all copies or substantial portions of the Software.
15 | "
16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | " }}}
24 | "=============================================================================
25 |
26 |
27 | if exists("b:current_syntax")
28 | finish
29 | endif
30 |
31 | let b:current_syntax = "stardict"
32 |
33 | syntax match stardictResult "\v^[A-Z].*"
34 | syntax match stardictWord "\v^\@.*"
35 | syntax match stardictWordType "\v^\*.*"
36 | syntax match stardictWordMeaning "\v^[0-9].*"
37 | syntax match stardictWordExample "\v^( \-\s.*\:|\!.*| \-\s.*)"
38 | syntax match stardictDictName "\v^\@[^/]*\:[^/]*"
39 |
40 | highlight link stardictResult Special
41 | highlight link stardictWord PreProc
42 | highlight link stardictWordType Statement
43 | highlight link stardictWordMeaning Identifier
44 | highlight link stardictWordExample Type
45 | highlight link stardictDictName Underlined
46 |
--------------------------------------------------------------------------------
/plugin/stardict.vim:
--------------------------------------------------------------------------------
1 | "=============================================================================
2 | " FILE: plugin/stardict.vim
3 | " AUTHOR: Phong V. Cao
4 | " License: MIT license {{{
5 | " Permission is hereby granted, free of charge, to any person obtaining
6 | " a copy of this software and associated documentation files (the
7 | " "Software"), to deal in the Software without restriction, including
8 | " without limitation the rights to use, copy, modify, merge, publish,
9 | " distribute, sublicense, and/or sell copies of the Software, and to
10 | " permit persons to whom the Software is furnished to do so, subject to
11 | " the following conditions:
12 | "
13 | " The above copyright notice and this permission notice shall be included
14 | " in all copies or substantial portions of the Software.
15 | "
16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | " }}}
24 | "=============================================================================
25 |
26 |
27 | if exists('g:loaded_stardict')
28 | finish
29 | endif
30 |
31 | if !exists('g:stardict_split_size')
32 | let g:stardict_split_size = ''
33 | endif
34 |
35 | if !exists('g:stardict_split_horizontal')
36 | let g:stardict_split_horizontal = 1
37 | endif
38 |
39 | if !exists('g:stardict_use_dict')
40 | let g:stardict_use_dict = ''
41 | endif
42 |
43 | if !exists('g:stardict_utf8_output')
44 | let g:stardict_utf8_output = 1
45 | endif
46 |
47 | if !exists('g:stardict_utf8_input')
48 | let g:stardict_utf8_input = 1
49 | endif
50 |
51 | if !exists('g:stardict_data_dir')
52 | let g:stardict_data_dir = '/usr/share/stardict/dic'
53 | endif
54 |
55 | if !exists('g:stardict_colorize_output')
56 | let g:stardict_colorize_output = 1
57 | endif
58 |
59 | " Map :StarDict command to stardict#StarDict() function
60 | command! -nargs=* StarDict call stardict#StarDict()
61 | " command! -nargs=* StarDictCursor call stardict#StarDict(, expand(''))
62 | command! -nargs=* StarDictCursor call stardict#StarDict( expand(''))
63 |
--------------------------------------------------------------------------------
/bindings/bash/stardict.sh:
--------------------------------------------------------------------------------
1 | #=============================================================================
2 | # FILE: bindings/bash/stardict.sh
3 | # AUTHOR: Phong V. Cao
4 | # License: MIT license {{{
5 | # Permission is hereby granted, free of charge, to any person obtaining
6 | # a copy of this software and associated documentation files (the
7 | # "Software"), to deal in the Software without restriction, including
8 | # without limitation the rights to use, copy, modify, merge, publish,
9 | # distribute, sublicense, and/or sell copies of the Software, and to
10 | # permit persons to whom the Software is furnished to do so, subject to
11 | # the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included
14 | # in all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | # }}}
24 | #=============================================================================
25 |
26 |
27 | export STARDICT_RESULT="\033[0;31m"
28 | export STARDICT_WORD="\033[0;91m"
29 | export STARDICT_WORD_TYPE="\033[0;32m"
30 | export STARDICT_WORD_MEANING="\033[0;34m"
31 | export STARDICT_WORD_EXAMPLE="\033[0;33m"
32 | export STARDICT_DICT_NAME="\033[0;95m"
33 | export STARDICT_PYTHON_PATH=""
34 |
35 | if [[ -z ${STARDICT_DIR} ]]; then
36 | export STARDICT_DIR="${HOME}/.vim/bundle/vim-stardict"
37 | fi
38 |
39 |
40 | function stardict() {
41 | if [[ -n "${STARDICT_PYTHON_PATH}" ]]; then
42 | "${STARDICT_PYTHON_PATH}" "${STARDICT_DIR}"/python/stardict.py "$@"
43 | else
44 | "${STARDICT_DIR}"/python/stardict.py "$@"
45 | fi
46 | }
47 |
48 |
49 | function vstardict() {
50 | PYSCRIPT_DIR="${STARDICT_DIR}"/python
51 | PYTHON_COMMAND="import sys; sys.path.insert(0, '"${PYSCRIPT_DIR}"')"
52 | VIM_COMMAND="setlocal buftype=nofile bufhidden=hide noswapfile readonly filetype=stardict"
53 |
54 | FINAL_DEFINITIONS=""
55 | ARGS_LIST=""
56 |
57 | if [[ -n "${STARDICT_PYTHON_PATH}" ]]; then
58 | FINAL_DEFINITIONS+="$(${STARDICT_PYTHON_PATH} -c "${PYTHON_COMMAND}; import stardict; print(stardict.getDefinition([['$@']]))")""\n""\n"
59 | else
60 | FINAL_DEFINITIONS+="$(python -c "${PYTHON_COMMAND}; import stardict; print(stardict.getDefinition([['$@']]))")""\n""\n"
61 | fi
62 |
63 | echo -e "${FINAL_DEFINITIONS}" | vim -c "${VIM_COMMAND}" -
64 | }
65 |
--------------------------------------------------------------------------------
/bindings/zsh/stardict.zsh:
--------------------------------------------------------------------------------
1 | #=============================================================================
2 | # FILE: bindings/zsh/stardict.zsh
3 | # AUTHOR: Phong V. Cao
4 | # License: MIT license {{{
5 | # Permission is hereby granted, free of charge, to any person obtaining
6 | # a copy of this software and associated documentation files (the
7 | # "Software"), to deal in the Software without restriction, including
8 | # without limitation the rights to use, copy, modify, merge, publish,
9 | # distribute, sublicense, and/or sell copies of the Software, and to
10 | # permit persons to whom the Software is furnished to do so, subject to
11 | # the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included
14 | # in all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | # }}}
24 | #=============================================================================
25 |
26 |
27 | export STARDICT_RESULT="\033[0;31m"
28 | export STARDICT_WORD="\033[0;91m"
29 | export STARDICT_WORD_TYPE="\033[0;32m"
30 | export STARDICT_WORD_MEANING="\033[0;34m"
31 | export STARDICT_WORD_EXAMPLE="\033[0;33m"
32 | export STARDICT_DICT_NAME="\033[0;95m"
33 | export STARDICT_PYTHON_PATH=""
34 |
35 | if [[ -z ${STARDICT_DIR} ]]; then
36 | export STARDICT_DIR="${HOME}/.vim/bundle/vim-stardict"
37 | fi
38 |
39 |
40 | function stardict() {
41 | if [[ -n "${STARDICT_PYTHON_PATH}" ]]; then
42 | "${STARDICT_PYTHON_PATH}" "${STARDICT_DIR}"/python/stardict.py "$@"
43 | else
44 | "${STARDICT_DIR}"/python/stardict.py "$@"
45 | fi
46 | }
47 |
48 |
49 | function vstardict() {
50 | PYSCRIPT_DIR="${STARDICT_DIR}"/python
51 | PYTHON_COMMAND="import sys; sys.path.insert(0, '"${PYSCRIPT_DIR}"')"
52 | VIM_COMMAND="setlocal buftype=nofile bufhidden=hide noswapfile readonly filetype=stardict"
53 |
54 | FINAL_DEFINITIONS=""
55 | ARGS_LIST=""
56 |
57 | if [[ -n "${STARDICT_PYTHON_PATH}" ]]; then
58 | FINAL_DEFINITIONS+="$(${STARDICT_PYTHON_PATH} -c "${PYTHON_COMMAND}; import stardict; print(stardict.getDefinition([['$@']]))")""\n""\n"
59 | else
60 | FINAL_DEFINITIONS+="$(python -c "${PYTHON_COMMAND}; import stardict; print(stardict.getDefinition([['$@']]))")""\n""\n"
61 | fi
62 |
63 | echo -e "${FINAL_DEFINITIONS}" | vim -c "${VIM_COMMAND}" -
64 | }
65 |
--------------------------------------------------------------------------------
/autoload/stardict.vim:
--------------------------------------------------------------------------------
1 | "=============================================================================
2 | " FILE: autoload/stardict.vim
3 | " AUTHOR: Phong V. Cao
4 | " License: MIT license {{{
5 | " Permission is hereby granted, free of charge, to any person obtaining
6 | " a copy of this software and associated documentation files (the
7 | " "Software"), to deal in the Software without restriction, including
8 | " without limitation the rights to use, copy, modify, merge, publish,
9 | " distribute, sublicense, and/or sell copies of the Software, and to
10 | " permit persons to whom the Software is furnished to do so, subject to
11 | " the following conditions:
12 | "
13 | " The above copyright notice and this permission notice shall be included
14 | " in all copies or substantial portions of the Software.
15 | "
16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | " }}}
24 | "=============================================================================
25 |
26 |
27 | " This is for setting up PYTHONPATH
28 | let s:script_folder_path = escape(expand(':p:h'), '\')
29 | let s:stardict_buf_count = 0
30 |
31 |
32 | function! s:SetPythonPath() abort
33 | if has('python3')
34 | python3 import sys
35 | python3 import vim
36 | execute 'python3 sys.path.insert(0, "' . s:script_folder_path . '/../python")'
37 | elseif has('python')
38 | python import sys
39 | python import vim
40 | execute 'python sys.path.insert(0, "' . s:script_folder_path . '/../python")'
41 | endif
42 |
43 | return 1
44 | endfunction
45 |
46 |
47 | function! stardict#StarDict(...)
48 | let l:expl=stardict#GetDefinition(a:000)
49 |
50 | if (&filetype != 'stardict')
51 | let l:cur_winnr = winnr()
52 | execute "normal! \b"
53 | if (winnr() > 1)
54 | exe "normal! " . l:cur_winnr . "\w"
55 | while 1
56 | if (&filetype == 'stardict')
57 | break
58 | endif
59 | exe "normal! \w"
60 | if (l:cur_winnr ==# winnr())
61 | break
62 | endif
63 | endwhile
64 | endif
65 | if &filetype != 'stardict'
66 | if (g:stardict_split_horizontal ==# 1)
67 | silent! execute g:stardict_split_size . 'sp vim-stardict' . s:stardict_buf_count
68 | else
69 | silent! execute g:stardict_split_size . 'vsp vim-stardict' . s:stardict_buf_count
70 | endif
71 | endif
72 | endif
73 |
74 | silent exec "1,$d"
75 | setlocal buftype=nofile bufhidden=hide noswapfile readonly filetype=stardict
76 | setlocal number relativenumber nobuflisted
77 | silent! 1s/^/\=l:expl/
78 | 1
79 | endfunction
80 |
81 |
82 | function! stardict#GetArgsList(orgArgs)
83 | if (g:stardict_use_dict)
84 | if ((index(a:orgArgs, '-u') == -1) && (index(a:orgArgs, '--use-dict') == -1))
85 | let a:orgArgs = insert(a:orgArgs, '--use-dict=' . g:stardict_use_dict, 0)
86 | endif
87 | endif
88 |
89 | if g:stardict_utf8_output
90 | if (index(a:orgArgs, '-0') == -1) && (index(a:orgArgs, '--utf8-output') == -1)
91 | let a:orgArgs = insert(a:orgArgs, '--utf8-output', 0)
92 | endif
93 | endif
94 |
95 | if g:stardict_utf8_input
96 | if (index(a:orgArgs, '-1') == -1) && (index(a:orgArgs, '--utf8-input') == -1)
97 | let a:orgArgs = insert(a:orgArgs, '--utf8-input', 0)
98 | endif
99 | endif
100 |
101 | if g:stardict_data_dir
102 | if (index(a:orgArgs, '-2') == -1) && (index(a:orgArgs, '--data-dir') == -1)
103 | let a:orgArgs = insert(a:orgArgs, '--data-dir=' . g:stardict_data_dir, 0)
104 | endif
105 | endif
106 |
107 | echom join(a:orgArgs, '\\ ')
108 |
109 | return a:orgArgs
110 | endfunction
111 |
112 |
113 | function! stardict#GetDefinition(...)
114 | if s:SetPythonPath() != 1
115 | return "Cannot set ${PATH} variable!"
116 | endif
117 |
118 | let l:args=stardict#GetArgsList(a:000)
119 | " let l:argsStr = join(l:args, '\\ ')
120 | let l:argsStr = join(a:000, '\\ ')
121 | " echom a:000
122 | " echom l:args
123 | " echom l:argsStr
124 |
125 | if has('python3')
126 | python3 definition = GetDefinitionInner(vim.eval('a:000'))
127 | let l:definition = py3eval('definition')
128 | elseif has('python')
129 | python definition = GetDefinitionInner(vim.eval('a:000'))
130 | let l:definition = pyeval('definition')
131 | endif
132 |
133 | return l:definition
134 | endfunction
135 |
136 | if has('python3')
137 | python3 << EOF
138 | def GetDefinitionInner(argsStr):
139 | import stardict
140 |
141 | return stardict.getDefinition(argsStr)
142 | EOF
143 | elseif has('python')
144 | python << EOF
145 | def GetDefinitionInner(argsStr):
146 | import stardict
147 |
148 | return stardict.getDefinition(argsStr)
149 | EOF
150 | else
151 | echom 'vim-stardict requires your Vim to be compiled with +python or +python3 option!'
152 | endif
153 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vim-stardict
2 |
3 | Project maintained by Phong V.
4 | Cao
5 |
6 | A Vim plugin for looking up meaning of words inside Vim, Bash and Zsh using the
7 | **StarDict Command-Line Version (SDCV)** dictionary program.
8 |
9 | In addition to opening a Vim split and populating it with the output of StarDict
10 | Command-Line Version (SDCV), **vim-stardict** takes advantage of Vim syntax
11 | highlighting and some basic regexes to present the words' definitions to the
12 | users in an organized and user-friendly way.
13 |
14 | The plugin was inspired by and originally a fork of
15 | [chusiang/vim-sdcv](https://github.com/chusiang/vim-sdcv).
16 |
17 |
18 | Screenshots
19 | ===========
20 |
21 | Lookup word under cursor in a :split (using :StarDictCursor command)
22 | --------------
23 | 
24 |
25 | Lookup word in a :vsplit (using :StarDict command)
26 | ---------------
27 | 
28 |
29 | Lookup word in Bash (using 'stardict' command)
30 | ---------------
31 | 
32 |
33 | Redirect Bash output to Vim (using 'vstardict' command)
34 | ---------------
35 | 
36 |
37 |
38 | Installation
39 | ============
40 |
41 | Before installing **vim-stardict** , the following applications need to be
42 | already installed in your computer:
43 |
44 | * [SDCV][0]
45 |
46 | There are several ways to install **vim-stardict**:
47 |
48 | * [Pathogen][1]
49 | * `git clone https://github.com/phongvcao/vim-stardict.git`
50 | * [NeoBundle][2]
51 | * `NeoBundle 'phongvcao/vim-stardict'`
52 | * [Vundle][3]
53 | * `Plugin 'phongvcao/vim-stardict'`
54 | * Manual
55 | * Copy all of the files into your `~/.vim` directory
56 |
57 |
58 | Usage
59 | =====
60 |
61 | ## 1. Vim:
62 | To lookup the meaning of a word with no-space-in-between:
63 |
64 | :StarDict random_word_with_no_spaces
65 |
66 | To lookup the meaning of a word with spaces-in-between, put it inside
67 | quotation marks (both double and single quotes are acceptable):
68 |
69 | :StarDict "random word with spaces"
70 | :StarDict 'random word with spaces'
71 |
72 | To look up the meaning of several words (either no-spaces-in-between or
73 | spaces-in-between):
74 |
75 | :StarDict first_word second_word "third word" 'fourth word'
76 | :StarDict "first word" 'second word'
77 |
78 | To lookup the meaning of a word under-the-cursor:
79 |
80 | :StarDictCursor
81 |
82 | You can pass arguments of command-line `sdcv` to `:StarDict` and `:StarDictCursor`
83 | commands in Vim:
84 |
85 | :StarDict first_word "second word" -u "my_dictionary" --data-dir /my/data/dir
86 | :StarDictCursor -u "my_dictionary" --data-dir /my/data/dir
87 |
88 |
89 |
90 | ## 2. Bash and Zsh:
91 | To lookup the meaning of a word with no-space-in-between:
92 |
93 | stardict random_word_with_no_spaces
94 |
95 | To lookup the meaning of a word with spaces-in-between, put it inside
96 | quotation marks (both double and single quotes are acceptable):
97 |
98 | stardict "random word with spaces"
99 | stardict 'random word with spaces'
100 |
101 | To look up the meaning of several words (either no-spaces-in-between or
102 | spaces-in-between):
103 |
104 | stardict first_word second_word "third word" 'fourth word'
105 | stardict "first word" 'second word'
106 |
107 | To view the meaning of word in Vim from Bash or Zsh:
108 |
109 | vstardict first_word second_word "third word" 'fourth word'
110 |
111 | You can pass arguments of command-line `sdcv` to `stardict` and `vstardict`
112 | commands in Bash and Zsh:
113 |
114 | stardict first_word "second word" -u "my_dictionary" --data-dir /my/data/dir
115 | vstardict 'first word' -u "my_dictionary" --data-dir /my/data/dir
116 |
117 |
118 | Configuration
119 | =============
120 |
121 | ## 1. Vim:
122 | Sample configuration for your `.vimrc` (more in the official documentation)
123 |
124 | ```vim
125 | " Make vim-stardict split open in a :split (default value)
126 | let g:stardict_split_horizontal = 1
127 |
128 | " Set vim-stardict split width (or height) to 20 based on whether
129 | " vim-stardict split is a :vsplit (or :split)
130 | let g:stardict_split_size = 20
131 |
132 | " Map vim-stardict's commands
133 | " Ready for typing the word in
134 | nnoremap sw :StarDict
135 | " Lookup the word under cursor
136 | nnoremap sc :StarDictCursor
137 |
138 | " OPTIONAL: You can change the colors of output of vim-stardict inside
139 | " Vim as follow (see below for the comprehensive list of highlight
140 | " group):
141 | " highlight link stardictResult Special " Default value
142 | " highlight link stardictWord PreProc " Default value
143 | " highlight link stardictWordType Statement " Default value
144 | " highlight link stardictWordMeaning Identifier " Default value
145 | " highlight link stardictWordExample Type " Default value
146 | " highlight link stardictDictName Underlined " Default value
147 | ```
148 |
149 | **For the full list of highlight groups in Vim**, you can consult [:help group-name][5]
150 |
151 |
152 | ## 2. Bash and Zsh:
153 | Sample configuration for your `.bashrc` (`.zshrc` is similar - please consult
154 | the documentation) (supposed you use [Vundle][3] to manage your plugins):
155 |
156 | ```sh
157 | # Export vim-stardict installation directory
158 | # NOTE: Only do this if your vim-stardict installation directory is other
159 | # than ${HOME}/.vim/bundle/vim-stardict. In other words, uncomment these
160 | # lines if you are not using Vundle, Pathogen or NeoBundle to manage your
161 | # Vim plugins:
162 | export STARDICT_DIR="{HOME}/.vim/bundle/vim-stardict"
163 |
164 | # For Bash: Source the stardict.sh file in the vim-stardict installation
165 | # directory.
166 | # For Zsh: The path to the stardict.zsh file is
167 | # "${HOME}"/.vim/bundle/vim-stardict/bindings/zsh/stardict.zsh
168 | if [[ -f "${HOME}"/.vim/bundle/vim-stardict/bindings/bash/stardict.sh ]]; then
169 | source "${HOME}"/.vim/bundle/vim-stardict/bindings/bash/stardict.sh
170 | fi
171 |
172 | # To avoid typing the long & daunting 'stardict' & 'vstardict'
173 | # commands, you can alias it to something else
174 | alias whatis="stardict"
175 | alias whatvim="vstardict"
176 |
177 | # OPTIONAL: You can change the colors of output of vim-stardict inside
178 | # Bash (see below for the comprehensive list of color codes in Bash):
179 | # export STARDICT_RESULT="\033[0;31m" # Defaut value
180 | # export STARDICT_WORD="\033[0;91m" # Defaut value
181 | # export STARDICT_WORD_TYPE="\033[0;32m" # Defaut value
182 | # export STARDICT_WORD_MEANING="\033[0;34m" # Defaut value
183 | # export STARDICT_WORD_EXAMPLE="\033[0;33m" # Defaut value
184 | # export STARDICT_DICT_NAME="\033[0;95m" # Defaut value
185 |
186 | # OPTIONAL: You can change the path to the python executable that
187 | # vim-stardict uses for Bash/Zsh lookup (which is "/usr/bin/python"
188 | # by default).
189 | # export STARDICT_PYTHON_PATH="/usr/bin/python" # Defaut value
190 | ```
191 |
192 | **For the full list of color codes in Bash and Zsh**, you can consult [this link][4]
193 |
194 | You can change **whatis** and **whatvim** above to whatever aliases you like.
195 | Also, you can change the path to source the **stardict.sh** file above, if your
196 | Vim plugin directory is different.
197 |
198 | With the above configuration, you can issue these commands to find meaning of
199 | words:
200 |
201 | whatis first_word second_word "third word" 'fourth word'
202 | whatvim first_word second_word "third word" 'fourth word'
203 |
204 |
205 | Documentation
206 | =============
207 | * See [:help vim-stardict](https://github.com/phongvcao/vim-stardict/blob/master/doc/vim-stardict.txt) VimDoc for more information.
208 |
209 |
210 | Contributors
211 | ============
212 | * Please read [CONTRIBUTING.md](https://github.com/phongvcao/vim-stardict/blob/master/CONTRIBUTING.md) before making your Pull Requests
213 | * See [vim-stardict contributors](https://github.com/phongvcao/vim-stardict/graphs/contributors) for the list of contributors
214 |
215 | *Thank you to you all!*
216 |
217 |
218 | Report Bugs
219 | ===========
220 | * If you find a bug please do not hesitate to post it (along with a screenshot
221 | of the bug, if applicable) on our [Github issue tracker](https://github.com/phongvcao/vim-stardict/issues/new).
222 |
223 |
224 | Credits
225 | =======
226 |
227 | * Special thanks to [chusiang](https://github.com/chusiang/) from whom I got
228 | the original idea from.
229 |
230 | [0]: http://sdcv.sourceforge.net/
231 | [1]: https://github.com/tpope/vim-pathogen
232 | [2]: https://github.com/Shougo/neobundle.vim
233 | [3]: https://github.com/gmarik/vundle
234 | [4]: https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash
235 | [5]: http://vimdoc.sourceforge.net/htmldoc/syntax.html#group-name
236 |
237 | Todo
238 | ====
239 | **vim-stardict** is currently under heavy development. Your contributions and
240 | patches are highly appreciated.
241 |
242 | * Add support for Windows
243 | * Implement word lookup in Visual Mode (look up the selected text)
244 | * Once opened under :StarDictCursor mode, whenever the mouse move to a new word,
245 | vim-stardict automatically looks up for that word (let g:stardict_lookup_on_mousemove)
246 |
--------------------------------------------------------------------------------
/python/stardict.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #
3 | # ============================================================================
4 | # FILE: python/stardict.py
5 | # AUTHOR: Phong V. Cao
6 | # License: MIT license {{{
7 | # Permission is hereby granted, free of charge, to any person obtaining
8 | # a copy of this software and associated documentation files (the
9 | # "Software"), to deal in the Software without restriction, including
10 | # without limitation the rights to use, copy, modify, merge, publish,
11 | # distribute, sublicense, and/or sell copies of the Software, and to
12 | # permit persons to whom the Software is furnished to do so, subject to
13 | # the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included
16 | # in all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 | # }}}
26 | # ============================================================================
27 |
28 |
29 | import sys
30 | import os
31 | import locale
32 | import re
33 | from subprocess import Popen, PIPE
34 |
35 |
36 | def main():
37 | sys.stdout.write(getDefinition([sys.argv[1:]], caller="bash"))
38 |
39 |
40 | def processArgsList(argsList):
41 | startArgPattern = "^(?:\\\"|\\').*"
42 | endArgPattern = ".*(?:\\\"|\\')$"
43 | finalArgsList = []
44 | i = 0
45 |
46 | while True:
47 | startArgIdx = i
48 |
49 | if (re.match(startArgPattern, argsList[i])):
50 | # If the current element matches the startArgPattern,
51 | # We keep incrementing i until being able to find
52 | # endArgPattern, or until i == len(argsList)
53 | while ((i < len(argsList)) and
54 | not(re.match(endArgPattern, argsList[i]))):
55 | i += 1
56 |
57 | endArgIdx = i
58 | tempList = argsList[startArgIdx:endArgIdx + 1]
59 |
60 | if (re.match(endArgPattern, argsList[i])):
61 | finalArgsList.append(" ".join(tempList))
62 | else:
63 | finalArgsList += tempList
64 |
65 | else:
66 | finalArgsList.append(argsList[i])
67 |
68 | i += 1
69 | if (i >= len(argsList)):
70 | break
71 |
72 | return finalArgsList
73 |
74 |
75 | def getDefinition(argsListList, caller="vim"):
76 | argsListList[0].insert(0, "-n")
77 | argsListList[0].insert(0, "sdcv")
78 |
79 | definition = Popen(" ".join(argsListList[0]), shell=True, stdout=PIPE)\
80 | .stdout.read()
81 | encoding = locale.getdefaultlocale()[1]
82 | definition = formatStr(definition.decode(encoding))
83 |
84 | if (caller == "bash"):
85 | stardictResult = "[A-Z].*"
86 | stardictWord = "\\@.*"
87 | stardictWordType = "\\*.*"
88 | stardictWordMeaning = "[0-9].*"
89 | stardictWordExample = "( \\-\\s.*\\:|\\!.*| \\-\\s.*)"
90 | stardictDictName = "\\@[^/]*\\:[^/]*"
91 | # The color codes were generated by running the following commands
92 | # in bash:
93 | #
94 | # for (( i = 0; i < 17; ++i ));
95 | # do echo "$(tput setaf $i)This is ($i) $(tput sgr0)";
96 | # done
97 | #
98 | # http://stackoverflow.com/a/25692021
99 | #
100 |
101 | nc = "\033[0m"
102 | preProcSubStr = os.environ["STARDICT_WORD"] + "\\1" + nc
103 | specialSubStr = os.environ["STARDICT_RESULT"] + "\\1" + nc
104 | statementSubStr = os.environ["STARDICT_WORD_TYPE"] + "\\1" + nc
105 | identifierSubStr = os.environ["STARDICT_WORD_MEANING"] + "\\1" + nc
106 | typeSubStr = os.environ["STARDICT_WORD_EXAMPLE"] + "\\1" + nc
107 | underlinedSubStr = os.environ["STARDICT_DICT_NAME"] + "\\1" + nc
108 |
109 | finalStr = ""
110 | replacedStr = ""
111 | startLineCharIdx = -1
112 |
113 | while True:
114 | endLineCharIdx = definition.find('\n', startLineCharIdx + 1)
115 |
116 | if (endLineCharIdx < 0):
117 | break
118 |
119 | # Also include newline as part of the extracted string
120 | line = definition[startLineCharIdx + 1:endLineCharIdx + 1]
121 |
122 | if (re.match("^" + stardictResult, line)):
123 | # Re-format stardictResult
124 | replacedStr = re.sub("^(" + stardictResult + ")",
125 | specialSubStr, line, flags=re.IGNORECASE)
126 |
127 | elif (re.match("^" + stardictDictName, line)):
128 | # Re-format stardictDictName
129 | replacedStr = re.sub("^(" + stardictDictName + ")",
130 | underlinedSubStr, line, flags=re.IGNORECASE)
131 |
132 | elif (re.match("^" + stardictWord, line)):
133 | # Re-format stardictWord
134 | replacedStr = re.sub("^(" + stardictWord + ")", preProcSubStr,
135 | line, flags=re.IGNORECASE)
136 |
137 | elif (re.match("^" + stardictWordType, line)):
138 | # Re-format stardictWordType
139 | replacedStr = re.sub("^(" + stardictWordType + ")",
140 | statementSubStr, line, flags=re.IGNORECASE)
141 |
142 | elif (re.match("^" + stardictWordMeaning, line)):
143 | # Re-format stardictWordMeaning
144 | replacedStr = re.sub("^(" + stardictWordMeaning + ")",
145 | identifierSubStr, line, flags=re.IGNORECASE)
146 |
147 | elif (re.match("^" + stardictWordExample, line)):
148 | # Re-format stardictWordExample
149 | replacedStr = re.sub("^(" + stardictWordExample + ")",
150 | typeSubStr, line, flags=re.IGNORECASE)
151 |
152 | else:
153 | replacedStr = line
154 |
155 | finalStr += replacedStr
156 | startLineCharIdx = endLineCharIdx
157 |
158 | return finalStr
159 |
160 | return definition
161 |
162 |
163 | def formatStr(outputStr):
164 | replacedBullet = 1
165 | wordMeaningPattern = "^\\-\\s+.*"
166 | wordExamplePattern = "^[=+].*"
167 | wordMultiExamplesPattern = "^\\!.*"
168 | wordPattern = "^\@.*"
169 | dictNamePattern = "^\\-\\-\\>.*"
170 | finalStr = ""
171 |
172 | startLineCharIdx = -1
173 | prevLineCharIdx = -1
174 |
175 | while True:
176 | endLineCharIdx = outputStr.find('\n', startLineCharIdx + 1)
177 |
178 | if (endLineCharIdx < 0):
179 | break
180 |
181 | # Also include newline as part of the extracted string
182 | line = outputStr[startLineCharIdx + 1:endLineCharIdx + 1]
183 |
184 | # The order of the if/elseif statements matter to the logic flow of
185 | # this function
186 | if (re.match(wordExamplePattern, line)):
187 | # Re-format WordExample
188 | replacedStr = re.sub("^[=+]\\s*", " - ", line,
189 | flags=re.IGNORECASE)
190 | replacedStr = re.sub("\\+\\s*", ": ", replacedStr,
191 | flags=re.IGNORECASE)
192 | finalStr += replacedStr
193 |
194 | elif (re.match(wordMeaningPattern, line)):
195 | # Re-format WordMeaning
196 | if (prevLineCharIdx > -1):
197 | prevLine = outputStr[prevLineCharIdx + 1:startLineCharIdx + 1]
198 |
199 | if (re.match(wordMultiExamplesPattern, prevLine)):
200 | replacedStr = re.sub("^\\-", " -", line,
201 | flags=re.IGNORECASE)
202 | else:
203 | replacedStr = re.sub("^\\-\\s+", str(replacedBullet) +
204 | ". ", line, flags=re.IGNORECASE)
205 | replacedBullet += 1
206 | finalStr += replacedStr
207 |
208 | elif (re.match(wordPattern, line)):
209 | # Re-format Word
210 | # replacedStr = re.sub("^\\@([^/0-9]+)", "\\1:", line,
211 | # flags=re.IGNORECASE)
212 | # finalStr += replacedStr
213 | finalStr += line
214 | replacedBullet = 1
215 | else:
216 | finalStr += line
217 |
218 | prevLineCharIdx = startLineCharIdx
219 | startLineCharIdx = endLineCharIdx
220 |
221 | finalStr2 = ""
222 | replacedBullet = 1
223 | startLineCharIdx = -1
224 |
225 | while True:
226 | endLineCharIdx = finalStr.find('\n', startLineCharIdx + 1)
227 |
228 | if (endLineCharIdx < 0):
229 | break
230 |
231 | # Also include newline as part of the extracted string
232 | line = finalStr[startLineCharIdx + 1:endLineCharIdx + 1]
233 |
234 | if (re.match(wordMultiExamplesPattern, line)):
235 | replacedStr = re.sub("^\\!(.*)", " - \\1:", line,
236 | flags=re.IGNORECASE)
237 | finalStr2 += replacedStr
238 |
239 | elif (re.match(dictNamePattern, line)):
240 | replacedStr = re.sub("^\\-\\-\\>", "@Dictionary: ", line,
241 | re.IGNORECASE)
242 | finalStr2 += replacedStr
243 |
244 | startLineCharIdx = endLineCharIdx
245 | endLineCharIdx = finalStr.find('\n', startLineCharIdx + 1)
246 | line = finalStr[startLineCharIdx + 1:endLineCharIdx + 1]
247 |
248 | replacedStr = re.sub("^\\-\\-\\>", "@SearchedTerm: ", line,
249 | re.IGNORECASE)
250 | finalStr2 += replacedStr
251 | else:
252 | finalStr2 += line
253 |
254 | startLineCharIdx = endLineCharIdx
255 |
256 | return finalStr2
257 |
258 |
259 | if __name__ == "__main__":
260 | main()
261 |
--------------------------------------------------------------------------------
/doc/vim-stardict.txt:
--------------------------------------------------------------------------------
1 | *stardict.txt* A Vim plugin for quick word-lookup using StarDict Command-Line
2 | Version (SDCV) dictionary program
3 |
4 | *Version:* *0.2.0* - Released on 02/26/2015
5 |
6 |
7 | ==============================================================================
8 | CONTENTS *vim-stardict-contents*
9 |
10 | 1. Introduction ....................... |vim-stardict-introduction|
11 | 2. Install ............................ |vim-stardict-install|
12 | 3. Usage .............................. |vim-stardict-usage|
13 | 4. Configuration ...................... |vim-stardict-configuration|
14 | 5. Mappings ........................... |vim-stardict-mappings|
15 | 6. License ............................ |vim-stardict-license|
16 | 7. Credits ............................ |vim-stardict-credits|
17 | 8. Bugs ............................... |vim-stardict-bugs|
18 | 9. Contributing ....................... |vim-stardict-contributing|
19 | 10. FAQ ................................ |vim-stardict-faq|
20 |
21 |
22 | ==============================================================================
23 | *1.INTRODUCTION* *vim-stardict-introduction*
24 |
25 | *vim-stardict* is a Vim plugin that helps users lookup for meaning of words right
26 | inside Vim and through *StarDict* *Command-Line* *Version* |SDCV|
27 | (http://sdcv.sourceforge.net/) - the console version of the popular |StarDict|
28 | program (http://www.stardict.org/).
29 |
30 | When the users invoke vim-stardict 's commands to search for words,
31 | vim-stardict opens either a |:vsplit| or |:split| and fill the buffer with
32 | well-highlighted and nicely-formatted definitions pulled out from the |StarDict|
33 | dictionaries located at |/usr/share/stardict/dic| (with the help of |SDCV|, of
34 | course).
35 |
36 |
37 | ==============================================================================
38 | *2.INSTALL* *vim-stardict-install*
39 |
40 | Before installing vim-stardict , the following applications need to be
41 | already installed in your computer:
42 |
43 | * |SDCV| : http://sdcv.sourceforge.net/
44 | * |Vim| : http://www.vim.org/
45 |
46 | There are several ways to install vim-stardict :
47 | * |Pathogen|:
48 | git clone https://github.com/phongvcao/vim-stardict.git
49 |
50 | * |NeoBundle|:
51 | NeoBundle 'phongvcao/vim-stardict'
52 |
53 | * |Vundle|:
54 | Plugin 'phongvcao/vim-stardict'
55 |
56 | * Manually copy all of the files into your |~/.vim| or
57 | |/usr/share/vim/vimfiles| directories
58 |
59 |
60 | ==============================================================================
61 | *3.USAGE* *vim-stardict-usage*
62 |
63 | ------------------------------------------------------------------------------
64 | *3.1* *Vim-Usage* *vim-usage*
65 |
66 | To lookup the meaning of a word with |no-space-in-between|:
67 |
68 | :StarDict random_word_with_no_spaces
69 |
70 | To lookup the meaning of a word with |spaces-in-between|, put it inside
71 | quotation marks (both double and single quotes are acceptable):
72 |
73 | :StarDict "random word with spaces"
74 | :StarDict 'random word with spaces'
75 |
76 | To look up the meaning of several words (either |no-spaces-in-between| or
77 | |spaces-in-between|):
78 |
79 | :StarDict first_word second_word "third word" 'fourth word'
80 | :StarDict "first word" 'second word'
81 |
82 | To lookup the meaning of a word |under-the-cursor|:
83 |
84 | :StarDictCursor
85 |
86 | ------------------------------------------------------------------------------
87 | *3.2* *Bash-Zsh-Usage* *bash-zsh-usage*
88 |
89 | To lookup the meaning of a word with |no-space-in-between|:
90 |
91 | stardict random_word_with_no_spaces
92 |
93 | To lookup the meaning of a word with |spaces-in-between|, put it inside
94 | quotation marks (both double and single quotes are acceptable):
95 |
96 | stardict "random word with spaces"
97 | stardict 'random word with spaces'
98 |
99 | To look up the meaning of several words (either |no-spaces-in-between| or
100 | |spaces-in-between|):
101 |
102 | stardict first_word second_word "third word" 'fourth word'
103 | stardict "first word" 'second word'
104 |
105 | To view the meaning of word in Vim from Bash or Zsh:
106 |
107 | vstardict first_word second_word "third word" 'fourth word'
108 |
109 |
110 | ==============================================================================
111 | *4.CONFIGURATION* *vim-stardict-configuration*
112 |
113 | *4.1* *Vim-Configuration* *vim-configuration*
114 |
115 | You can tweak the behavior of vim-stardict by setting a few variables in your
116 | |.vimrc| file. For example:
117 |
118 | let g:stardict_split_size = 20
119 | let g:stardict_split_horizontal = 1
120 |
121 | " OPTIONAL: You can change the colors of output of vim-stardict inside Vim
122 | " as follow (see below for the comprehensive list of highlight group):
123 | highlight link stardictResult Special " Default value
124 | highlight link stardictWord PreProc " Default value
125 | highlight link stardictWordType Statement " Default value
126 | highlight link stardictWordMeaning Identifier " Default value
127 | highlight link stardictWordExample Type " Default value
128 | highlight link stardictDictName Underlined " Default value
129 |
130 | For the full list of highlight groups in Vim, you can consult ':help group-name'
131 |
132 | ------------------------------------------------------------------------------
133 | *4.1.1* *g:stardict_split_size* *stardict_split_size*
134 |
135 | This is the size of the vim-stardict split. The value of g:stardict_split_size
136 | can be either a number or an empty string ''.
137 |
138 | * If a number is specified, the vim-stardict |:split| (or |:vsplit|) will
139 | have its |height| (or |width|) set accordingly to the number.
140 |
141 | * If an emptry string (default value) is specified, the vim-stardict
142 | |:split| (or |:vsplit|) will occupy half of the current window's |height|
143 | (or |width|).
144 |
145 | Default: '' (empty string)
146 |
147 | ------------------------------------------------------------------------------
148 | *4.1.2* *g:stardict_split_horizontal* *stardict_split_horizontal*
149 |
150 | This option specify whether to use a |:split| or a |:vsplit| for the
151 | vim-stardict split.
152 |
153 | * If set to 1, vim-stardict will be opened in a |:split|
154 | * If set to 0, vim-stardict will be opened in a |:vplit|
155 |
156 | Default: 1
157 |
158 | -----------------------------------------------------------------------------
159 | *4.2* *Bash-Zsh-Configuration* *bash-zsh-configuration*
160 |
161 | In order to use this plugin for Bash and Zsh also, you need to configure your
162 | |.bashrc| (or |.zshrc|) similar to the following (supposed you use |Vundle| to
163 | manage your plugins):
164 |
165 | # Export vim-stardict installation directory
166 | # NOTE: Only do this if your vim-stardict installation directory is other
167 | # than ${HOME}/.vim/bundle/vim-stardict. In other words, uncomment these
168 | # lines if you are not using Vundle, Pathogen or NeoBundle to manage your
169 | # Vim plugins:
170 | export STARDICT_DIR="{HOME}/.vim/bundle/vim-stardict"
171 |
172 | # For Bash: Source the stardict.sh file in the vim-stardict installation
173 | # directory.
174 | # For Zsh: The path to the stardict.zsh file is
175 | # "${HOME}"/.vim/bundle/vim-stardict/bindings/zsh/stardict.zsh
176 | if [[ -f "${HOME}"/.vim/bundle/vim-stardict/bindings/bash/stardict.sh ]]; then
177 | source "${HOME}"/.vim/bundle/vim-stardict/bindings/bash/stardict.sh
178 | fi
179 |
180 | # To avoid typing the long & daunting 'stardict' & 'vstardict' commands,
181 | # you can alias it to something else
182 | alias whatis="stardict"
183 | alias whatvim="vstardict"
184 |
185 | # OPTIONAL: You can change the colors of output of vim-stardict inside Bash
186 | # (see below for the comprehensive list of color codes in Bash):
187 | # export STARDICT_RESULT="\033[0;31m" # Defaut value
188 | # export STARDICT_WORD="\033[0;91m" # Defaut value
189 | # export STARDICT_WORD_TYPE="\033[0;32m" # Defaut value
190 | # export STARDICT_WORD_MEANING="\033[0;34m" # Defaut value
191 | # export STARDICT_WORD_EXAMPLE="\033[0;33m" # Defaut value
192 | # export STARDICT_DICT_NAME="\033[0;95m" # Defaut value
193 |
194 | # OPTIONAL: You can change the path to the python executable that
195 | # vim-stardict uses for Bash/Zsh lookup (which is "/usr/bin/python"
196 | # by default)
197 | # export STARDICT_PYTHON_PATH="/usr/bin/python" # Defaut value
198 |
199 | For the full list of color codes in Bash and Zsh, you can consult this link:
200 | http://vimdoc.sourceforge.net/htmldoc/syntax.html#group-name
201 |
202 | You can change 'whatis' and 'whatvim' to whatever aliases you like. Also, you
203 | can also change the path to source the |stardict.sh| file above, if your Vim
204 | plugin directory is different.
205 |
206 | With the above configuration, you can issue these commands to find meaning of
207 | words:
208 |
209 | whatis first_word second_word "third word" 'fourth word'
210 | whatvim first_word second_word "third word" 'fourth word'
211 |
212 |
213 | ==============================================================================
214 | *5.MAPPINGS* *vim-stardict-mappings*
215 |
216 | To save some keystrokes, instead of typing in the many vim-stardict commands
217 | directly, you can map them into Vim keymappings:
218 |
219 | nnoremap sw :StarDict " Ready for typing the word in
220 | nnoremap sc :StarDictCursor " Lookup the word under cursor
221 |
222 |
223 | ==============================================================================
224 | *6.LICENSE* *vim-stardict-license*
225 |
226 | Version: 0.1.0
227 | Author : Phong V. Cao
228 | Documentation Author: Phong V. Cao
229 | License: MIT license {{{
230 | Permission is hereby granted, free of charge, to any person obtaining
231 | a copy of this software and associated documentation files (the
232 | "Software"), to deal in the Software without restriction, including
233 | without limitation the rights to use, copy, modify, merge, publish,
234 | distribute, sublicense, and/or sell copies of the Software, and to
235 | permit persons to whom the Software is furnished to do so, subject to
236 | the following conditions:
237 | The above copyright notice and this permission notice shall be included
238 | in all copies or substantial portions of the Software.
239 |
240 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
241 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
242 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
243 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
244 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
245 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
246 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
247 | }}}
248 |
249 |
250 | ==============================================================================
251 | *7.Credits* *vim-stardict-credits*
252 |
253 | I would like to say special thanks and appreciation for the ideas, codes and
254 | inspirations from the following developers. Without them, I would never be so
255 | motivated (and have the idea/skeleton codes) to finish vim-stardict :
256 |
257 | * Chu-Siang Lai
258 | * Yunt
259 |
260 | Note: vim-stardict was actually started as a fork of |chusiang/vim-sdcv| on
261 | Github: https://github.com/chusiang/vim-sdcv, but due to so many extra codes and
262 | editation that I put in that I decided to go ahead and detach vim-stardict to a
263 | separate project instead of a fork. However, credits should still be due to
264 | where it is supposed to be due.
265 |
266 |
267 | ==============================================================================
268 | *8.Bugs* *vim-stardict-bugs*
269 |
270 | If you find a bug please do not hesitate to post it on our Github issue
271 | tracker:
272 |
273 | https://github.com/phongvcao/vim-stardict/issues/new
274 |
275 |
276 | ==============================================================================
277 | *9.Contributing* *vim-stardict-contributing*
278 |
279 | Think you can make this plugin better? Fork it on Github and send us a pull
280 | request:
281 |
282 | * |Github|: https://github.com/phongvcao/vim-stardict
283 |
284 |
285 | ==============================================================================
286 | *10.Changelog* *vim-stardict-changelog*
287 |
288 | |v0.5.0|
289 | * :StarDict command now accepts --data-dir & -u arguments
290 | * stardict & vstardict commands for Bash/Zsh now accepts all arguments of
291 | sdcv
292 |
293 | |v0.4.4|
294 | * Fixed stardict.py Python piping issue that prevents sdcv -u from getting
295 | the definition
296 |
297 | |v0.4.3|
298 | * Switched back to /usr/bin/python instead of /usr/bin/env python
299 |
300 | |v0.4.2|
301 | * Replaced /usr/bin/python with /usr/bin/env python for stardict.py
302 | * Added STARDICT_PYTHON_PATH variable to let users specify the python
303 | executable they want to use to execute stardict.py
304 | * Added CONTRIBUTING.md
305 |
306 | |v0.4.1|
307 | * Fixed default Python 3 option
308 | * Removed syntax file sourcing
309 | * Removed g:stardict_prefer_python3 option
310 |
311 | |v0.4.0|
312 | * Added support for Zsh
313 | * Added custom $STARDICT_DIR variable to let users specify vim-stardict
314 | installation directory
315 |
316 | |v0.3.3|
317 | * Fixed wrong highlighting of words' examples
318 |
319 | |v0.3.2|
320 | * Fixed :split and :vsplit opening delay
321 | * Fixed multiple :split open at a time
322 | * Reuse last 'stardict' buffer if there is one
323 | * Hide 'vim-stardict' buffer from buffer list
324 | * Removed buffer cache of old word meaning history
325 | * Added Report Bugs section on README.md
326 |
327 | |v0.3.1|
328 | * Restored mouse cursor after viewing definition
329 | * Added LICENSE.txt
330 |
331 | |v0.3.0|
332 | * Added output colors customization for Vim and Bash
333 | * Fixed extra split in Vim
334 |
335 | |v0.2.0|
336 | * Added support for Bash
337 | * Added output redirection from Bash to Vim
338 | * Fixed some highlight errors on Vim and Bash
339 | * Changed highlighting color for "Found ... items"
340 |
341 | |v0.1.0|:
342 | * Initial stable release
343 |
344 |
345 |
--------------------------------------------------------------------------------