Browse Source

vim: ++look-up

Maxim Likhachev 6 years ago
parent
commit
4d2186aac5
  1. 1
      etc/soft/vim/vim/+plugins/look-up
  2. 48
      etc/soft/vim/vim/+plugins/look-up/README.md
  3. BIN
      etc/soft/vim/vim/+plugins/look-up/look-up.png
  4. 82
      etc/soft/vim/vim/+plugins/look-up/plugin/look-up.vim
  5. 35
      etc/soft/vim/vim/+plugins/look-up/syntax/dict.vim

1
etc/soft/vim/vim/+plugins/look-up

@ -1 +0,0 @@ @@ -1 +0,0 @@
Subproject commit f036b1e99dbba6f8e06c8eedad29f13d15cb2207

48
etc/soft/vim/vim/+plugins/look-up/README.md

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
**look-up** - vim-plugin for sdcv
##Licence
Copyright (C) 2009-2015, Maksim Likhachev, <envrm@yandex.ru>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program. If not, see <http://www.gnu.org/licenses/>.
##Description
This script looks up a word under cursor in a dictionary using custom utility
such as sdcv (console version of StarDict program) and store the word into
text file with extension ".dict" in current directory (optionally).
##Installation
Put this file into your $HOME/.vim/plugin directory (our use
Pathogen/Vundle/etc) and configure your own keymaps.
For example:
> nmap fw :call Dict(expand("<cword>"))<CR>
> vnoremap fw :call Dict(@*)<CR>
The next two option set sdcv's command line and enables saving the words
into file:
> let g:sdcv_cmd = "sdcv -n "
> let g:sdcv_save = 1
##Usage
:Dict(<word>)
##Version
1.0
##Screenshot
![][structure]
[structure]:look-up.png

BIN
etc/soft/vim/vim/+plugins/look-up/look-up.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

82
etc/soft/vim/vim/+plugins/look-up/plugin/look-up.vim

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
" File: look-up.vim
" Author: Maksim Likhachev <envrm@yandex.ru>
" Version: 1.0
" License: GPL3
"
" Description:
" This script looks up a word under cursor in a dictionary using custom utility
" such as sdcv (console version of StarDict program) and store the word into
" text file with extension ".dict" in current directory (optionally).
"
" Installation:
" Put this file into your $HOME/.vim/plugin directory and configure your own
" keymaps.
"
" For example:
" nmap fw :call Dict(expand("<cword>"))<CR>
" vnoremap fw :call Dict(@*)<CR>
"
" The next two option set sdcv's command line and enables saving the words
" into file:
" let g:sdcv_cmd = "sdcv -n "
" let g:sdcv_save = 1
if !exists("g:sdcv_cmd")
let g:sdcv_cmd = "sdcv -n "
endif
if !exists("g:sdcv_save")
let g:sdcv_save = 1
endif
fun! OpenDictionary(cmd, ...)
if a:0
let buf_name = a:1
else
let buf_name = 'Dictionary'
endif
exe 'silent new' escape(buf_name, '\ ')
setlocal modifiable buftype=nofile noswapfile
let &ft = 'dict'
exe "silent 0r!".a:cmd." \"".a:1."\""
let helpsize = line('$')
if helpsize > &helpheight
let helpsize = &helpheight
endif
set nomod
if winheight(2) != -1
exe 'resize' helpsize
endif
noremap <buffer> <Space> <C-F>
noremap <buffer> <Backspace> <C-B>
noremap <buffer> q :bdel<CR>
if has("gui_running")
noremap <buffer> <Esc> :bdel<CR>
endif
setlocal foldmethod=indent
setlocal nohlsearch
setlocal nomodifiable
hi Error ctermfg=NONE ctermbg=NONE
endfun
fun! Dict(word)
echo a:word
if g:sdcv_save == 1
if filereadable(expand('%:p'))
let dict = expand('%:p') . ".dict"
call writefile(readfile(dict)+[a:word], dict)
endif
endif
call OpenDictionary(g:sdcv_cmd, a:word)
normal gg
endfun

35
etc/soft/vim/vim/+plugins/look-up/syntax/dict.vim

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
" Vim syntax file
" Language: stardict
" Author: Lihachev Maxim
" Created: Th 16 Apr 2009 10:18:10
" Modified: Вс 29 ноя 2015 20:20:45
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn region article start=/-->/ end=/$/
syn region transcription start=/\[/ end=/\]/
syn match category /_.*/
syn match list /^\s*[0-9a-zа-я]\()\|>\|\.\)/
if !exists("did_dict_syntax_inits")
let did_dict_syntax_inits = 1
hi link article hArticle
hi default hArticle ctermfg=lightblue
hi link category hCategory
hi default hCategory ctermfg=lightgreen
hi link list hList
hi default hList ctermfg=brown
hi link transcription hTranscription
hi default hTranscription ctermfg=lightyellow
endif
let b:current_syntax="dict"
Loading…
Cancel
Save