plugin setting for editting hy-lang on vim.
This is example.
on emacs ... emacs has hy-mode
.
But we need vim.
Step 1) 'plug' install
plug
is plugin manager for vim.
eg. download plug
program within install script for unix like system OS.
In terminal
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
you can check installed plugin manager
ls ~/.vim
there is autoload
derectory.
ls ~/.vim
autoload
Step 2) make new directory for vim plugins
In terminal
cd ~/.vim
mkdir plugged
Yes, you should check ~/.vim
ls ~/.vim
autoload plugged
Step 3) edit 'vimrc' file for setting up 'plug'
open .vimrc
in terminal.
vim ~/.vimrc
In vim
call plug#begin('~/.vim/plugged')
"comment... "vim plugin for syntax highlight"
Plug 'hylang/vim-hy'
call plug#end()
:vim plugin
vim-hy syntax
Step 4) open vim and install plugins
open vim by terminal command
vim test4.hy
In vim
vim command on vim screen
vim:test4.hy :PlugInstall
again in terminal.ls
command for check inside .vim
directory.
ls ~/.vim
autoload plugged
Can you find installed plugins in youre directory ? This case its vim-hy
ls ~/.vim/plugged
vim-hy
Step 5) check .hy file on vim
now vim syntax highlight hay-lang
In vim
sample) test4.hy
(import re requests)
(import [bs4 [BeautifulSoup]]) ;;;;★
;################################################
(setv url (get sys.argv 1)) ;;;;★★★
;(setv url "https://www.amazon.co.jp/%E3%82%AF%E3%83%AC%E3%82%A2-%E3%83%99%E3%82%B5%E3%83%B3%E3%83%88/dp/4806714828/ref=rvi_1/356-6811519-9296902?pd_rd_w=Isp3Z&pf_rd_p=05f9357d-2660-44e0-b122-56aa042de4a7&pf_rd_r=BZ9Y2WDDRFAF27EV3E7D&pd_rd_r=fb7859cc-210f-4e59-bc6a-9a052e73aeae&pd_rd_wg=dCXre&pd_rd_i=4806714828&psc=1")
;(setv url "https://www.amazon.co.jp/-/en/Ryzen-3600-Domestic-Authorized-100-10000031BOX/dp/B07STGGQ18/ref=sr_1_1?keywords=ryzen5+3600&qid=1636423814&sr=8-1")
;################################################
(setv uAgent {"User-Agent" "Mozilla/5.0 (Linux; Android 9) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36"}) ;;;;★★★★
(setv r-dict {"referer" "https://google.com/"})
(setv r-uAgent {#** r-dict #** uAgent})
(defn po [hoge] (print hoge :end " | "))
(setv session (.Session requests))
(setv response (session.get url :headers r-uAgent)) ;;;;★★★★
(.close response)
(del session)
(setv html_text response.text)
;;(po html_text)
;;(print response.cookies)
;;(print response.content)
;;(print response.headers)
(print "")
;################################################
(setv soup (BeautifulSoup html_text "html.parser"))
(setv page_title soup.title.string)
(setv review (.find_all soup "div" :class_ "a-expander-content reviewText review-text-content a-expander-partial-collapse-content"))
(setv rev-date (.find_all soup "span" :class_ "a-size-base a-color-secondary review-date"))
(setv rev-uname (.find_all soup "span" :class_ "a-profile-name"))
;(setv rev-star (.find_all soup "div" "a-profile-content"))
#_(comment
(po (str review)) ;check
(po (len rev-uname)) ;check
)
(setv i 0)
(for [v review]
(setv vs (str (.find v "span")))
(setv vsv (re.sub r"\<span\>\s|\<\/span\>" "" vs))
(setv vsv (re.sub r"\<span\sclass\=\"cr\-original\-review\-content\"" "" vsv))
(print "++++++++++++++++++")
(setv uv (get rev-uname i))
(setv dv (get rev-date i))
(setv vuv (re.search r"(?<=\"\>).*?(?=\<\/s)" (str uv)))
(print page_title)
(po (.group vuv))
(setv vdv (re.search r"(?<=\"\>).*?(?=\<\/s)" (str dv)))
(print (.group vdv))
(setv i (+ i 1))
(print (str vsv))
(re.purge)
)
vim-hy
not suports 'multiline comment' highlight.
#_(comment
comment body1
comment body1
)
cp.This(#figure) is "clojure" syntax highlight.
#figure
hy code but clojure syntax highlight
luochen1990/rainbow plugin case
cf.https://leetschau.github.io/hy-notes.html
In the default configuration, vim does not recognize .hy type files. In order to make vim plug-ins work in hy files, there are two methods:
Define a new file type and require the plug-in to render it: the advantage is that the definition is accurate, but the disadvantage is that it is invalid for some plug-ins;
Mapping the new file type to an existing mainstream file type: the advantage is that it has a wide range of applications, but the disadvantage is that there must be a very similar mainstream file type, and the rendering is based on the mainstream language, which is not particularly accurate for the new language ;
:case Step 3).vimrc
vim plugin
'luochen1990/rainbow'call plug#begin('~/.vim/plugged')
" Rainbow Parenthesis
au BufRead,BufNewFile *.hy setfiletype hy
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'ctermfgs': ['yellow', 'red', 'white', 'green', 'lightblue', 'lightred', 'lightgreen'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'hy': {
\ 'ctermfgs': ['yellow', 'red', 'white', 'green', 'lightblue', 'lightred', 'darkgreen'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
Plug 'luochen1990/rainbow'
call plug#end()
Step 4)
In v1im
'luochen1990/rainbow' install vim command on vim screen.
:PlugInstall
vim-hy + rainbow
call plug#begin('~/.vim/plugged')
"vim plugin for syntax highlight
Plug 'hylang/vim-hy'
" Rainbow Parenthesis
au BufRead,BufNewFile *.hy setfiletype hy
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'ctermfgs': ['yellow', 'red', 'white', 'green', 'lightblue', 'lightred', 'lightgreen'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'hy': {
\ 'ctermfgs': ['yellow', 'red', 'white', 'green', 'lightblue', 'lightred', 'darkgreen'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
Plug 'luochen1990/rainbow'
call plug#end()