mirror of
https://git.davidovski.xyz/dot.git
synced 2024-08-15 00:43:28 +00:00
initial commit
This commit is contained in:
commit
01ced0b7ce
184 changed files with 35358 additions and 0 deletions
62
config/vim/plugin/colorizer.vim
Normal file
62
config/vim/plugin/colorizer.vim
Normal file
|
@ -0,0 +1,62 @@
|
|||
" colorizer.vim Colorize all text in the form #rrggbb or #rgb; entrance
|
||||
" Maintainer: lilydjwg <lilydjwg@gmail.com>
|
||||
" Version: 1.4.1
|
||||
" Licence: Vim license. See ':help license'
|
||||
" Derived From: css_color.vim
|
||||
" http://www.vim.org/scripts/script.php?script_id=2150
|
||||
" Thanks To: Niklas Hofer (Author of css_color.vim), Ingo Karkat, rykka,
|
||||
" KrzysztofUrban, blueyed, shanesmith
|
||||
" Usage:
|
||||
"
|
||||
" This plugin defines three commands:
|
||||
"
|
||||
" ColorHighlight - start/update highlighting
|
||||
" ColorClear - clear all highlights
|
||||
" ColorToggle - toggle highlights
|
||||
"
|
||||
" By default, <leader>tc is mapped to ColorToggle. If you want to use another
|
||||
" key map, do like this:
|
||||
" nmap ,tc <Plug>Colorizer
|
||||
"
|
||||
" If you want completely not to map it, set the following in your vimrc:
|
||||
" let g:colorizer_nomap = 1
|
||||
"
|
||||
" To use solid color highlight, set this in your vimrc (later change won't
|
||||
" probably take effect unless you use ':ColorHighlight!' to force update):
|
||||
" let g:colorizer_fgcontrast = -1
|
||||
" set it to 0 or 1 to use a softened foregroud color.
|
||||
"
|
||||
" If you don't want to enable colorizer at startup, set the following:
|
||||
" let g:colorizer_startup = 0
|
||||
"
|
||||
" Note: if you modify a color string in normal mode, if the cursor is still on
|
||||
" that line, it'll take 'updatetime' seconds to update. You can use
|
||||
" :ColorHighlight (or your key mapping) again to force update.
|
||||
"
|
||||
" Performace Notice: In terminal, it may take several seconds to highlight 240
|
||||
" different colors. GUI version is much quicker.
|
||||
|
||||
" Reload guard and 'compatible' handling {{{1
|
||||
if exists("loaded_colorizer") || v:version < 700 || !(has("gui_running") || &t_Co == 256)
|
||||
finish
|
||||
endif
|
||||
let loaded_colorizer = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
"Define commands {{{1
|
||||
command! -bar -bang ColorHighlight call colorizer#ColorHighlight(1, "<bang>")
|
||||
command! -bar ColorClear call colorizer#ColorClear()
|
||||
command! -bar ColorToggle call colorizer#ColorToggle()
|
||||
nnoremap <silent> <Plug>Colorizer :ColorToggle<CR>
|
||||
if !hasmapto("<Plug>Colorizer") && (!exists("g:colorizer_nomap") || g:colorizer_nomap == 0)
|
||||
nmap <unique> <Leader>tc <Plug>Colorizer
|
||||
endif
|
||||
if !exists('g:colorizer_startup') || g:colorizer_startup
|
||||
call colorizer#ColorHighlight(0)
|
||||
endif
|
||||
|
||||
" Cleanup and modelines {{{1
|
||||
let &cpo = s:save_cpo
|
||||
" vim:ft=vim:fdm=marker:fmr={{{,}}}:
|
191
config/vim/plugin/emmet.vim
Normal file
191
config/vim/plugin/emmet.vim
Normal file
|
@ -0,0 +1,191 @@
|
|||
"=============================================================================
|
||||
" File: emmet.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 26-Jul-2015.
|
||||
" Version: 0.86
|
||||
" WebPage: http://github.com/mattn/emmet-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://emmet.io/
|
||||
" Usage:
|
||||
"
|
||||
" This is vim script support expanding abbreviation like emmet.
|
||||
" ref: http://emmet.io/
|
||||
"
|
||||
" Type abbreviation
|
||||
" +-------------------------------------
|
||||
" | html:5_
|
||||
" +-------------------------------------
|
||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
||||
" NOTE: Don't worry about key map. you can change it easily.
|
||||
" +-------------------------------------
|
||||
" | <!DOCTYPE HTML>
|
||||
" | <html lang="en">
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
" | </body>
|
||||
" | </html>
|
||||
" +-------------------------------------
|
||||
" Type following
|
||||
" +-------------------------------------
|
||||
" | div#foo$*2>div.bar
|
||||
" +-------------------------------------
|
||||
" And type "<c-y>,"
|
||||
" +-------------------------------------
|
||||
" |<div id="foo1">
|
||||
" | <div class="bar">_</div>
|
||||
" |</div>
|
||||
" |<div id="foo2">
|
||||
" | <div class="bar"></div>
|
||||
" |</div>
|
||||
" +-------------------------------------
|
||||
"
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be merged at loading plugin.
|
||||
"
|
||||
" let g:user_emmet_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
" \ 'perl' : {
|
||||
" \ 'aliases' : {
|
||||
" \ 'req' : 'require '
|
||||
" \ },
|
||||
" \ 'snippets' : {
|
||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
||||
" \ 'warn' : "warn \"|\";",
|
||||
" \ }
|
||||
" \ }
|
||||
" \}
|
||||
"
|
||||
" You can set language attribute in html using 'emmet_settings.lang'.
|
||||
"
|
||||
" GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim
|
||||
" script type: plugin
|
||||
|
||||
if &compatible || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_emmet_vim = 1
|
||||
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
if !exists('g:emmet_html5')
|
||||
let g:emmet_html5 = 1
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_docroot')
|
||||
let g:emmet_docroot = {}
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_debug')
|
||||
let g:emmet_debug = 0
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_curl_command')
|
||||
let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0'
|
||||
endif
|
||||
|
||||
if !exists('g:user_emmet_leader_key')
|
||||
let g:user_emmet_leader_key = '<c-y>'
|
||||
endif
|
||||
|
||||
function! s:install_plugin(mode, buffer)
|
||||
let buffer = a:buffer ? '<buffer>' : ''
|
||||
let items = [
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(0,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(3,"")<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(2,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': ':call emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': ':call emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': ':call emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': '<esc>:call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': ':call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': '<esc>:call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': ':call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': ':call emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageEncode()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': ':call emmet#imageEncode()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': ':call emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': '<esc>:call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': ':call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': ':call emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
||||
\]
|
||||
|
||||
let only_plug = get(g:, 'emmet_install_only_plug', 0)
|
||||
for item in items
|
||||
if a:mode !=# 'a' && stridx(a:mode, item.mode) == -1
|
||||
continue
|
||||
endif
|
||||
exe item.mode . 'noremap '. buffer .' <plug>(' . item.plug . ') ' . item.func
|
||||
if item.var != '' && !only_plug
|
||||
if exists('g:' . item.var)
|
||||
let key = eval('g:' . item.var)
|
||||
else
|
||||
let key = g:user_emmet_leader_key . item.key
|
||||
endif
|
||||
if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode))
|
||||
exe item.mode . 'map ' . buffer . ' <unique> ' . key . ' <plug>(' . item.plug . ')'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('g:user_emmet_complete_tag') && g:user_emmet_complete_tag
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
set omnifunc=emmet#completeTag
|
||||
else
|
||||
setlocal omnifunc=emmet#completeTag
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
command! -nargs=0 -bar EmmetInstall call <SID>install_plugin(get(g:, 'user_emmet_mode', 'a'), 1)
|
||||
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
call s:install_plugin(get(g:, 'user_emmet_mode', 'a'), 0)
|
||||
endif
|
||||
|
||||
if get(g:, 'user_emmet_install_command', 1)
|
||||
command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>)
|
||||
endif
|
||||
|
||||
function! s:setup_styledEmmetAbbreviation() abort
|
||||
if index(['javascript', 'javascriptreact', 'typescript', 'typescriptreact'], &filetype) != -1
|
||||
syntax match styledEmmetAbbreviation "[a-z0-9#+!%]\+" containedin=styledDefinition contained
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup ___emmet_setup___
|
||||
au!
|
||||
autocmd Syntax * call s:setup_styledEmmetAbbreviation()
|
||||
augroup END
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et:
|
45
config/vim/plugin/pickachu.vim
Normal file
45
config/vim/plugin/pickachu.vim
Normal file
|
@ -0,0 +1,45 @@
|
|||
"Script: Pickachu
|
||||
"Version: 0.0.1
|
||||
"Copyright: Copyright (C) 2018 Doug Beney
|
||||
"Licence:
|
||||
"Website: https://dougie.io
|
||||
|
||||
if !has('python3')
|
||||
echo "You need Vim Python3 support to use this plugin. If you're using NeoVim, try running `pip3 install neovim` to resolve this issue."
|
||||
endif
|
||||
|
||||
if !exists('g:pickachu_default_app')
|
||||
let g:pickachu_default_app = "color"
|
||||
endif
|
||||
|
||||
if !exists("g:pickachu_default_command")
|
||||
let g:pickachu_default_command = "zenity"
|
||||
endif
|
||||
|
||||
if !exists("g:pickachu_default_date_format")
|
||||
let g:pickachu_default_date_format = "%m/%d/%Y"
|
||||
endif
|
||||
|
||||
if !exists("g:pickachu_default_color_format")
|
||||
let g:pickachu_default_color_format = "hex"
|
||||
endif
|
||||
|
||||
function! s:pickachuCompletion(ArgLead, CmdLine, CursorPos)
|
||||
let options = ['color', 'date', 'file']
|
||||
return options
|
||||
endfunction
|
||||
|
||||
command! -nargs=* -complete=customlist,<SID>pickachuCompletion Pickachu call Pickachu(<f-args>)
|
||||
|
||||
python3 import sys
|
||||
python3 import vim
|
||||
python3 sys.path.append(vim.eval('expand("<sfile>:h")'))
|
||||
|
||||
function! Pickachu(...)
|
||||
python3 << EOF
|
||||
from pickachu.main import MainFunction
|
||||
MainFunction()
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
" vim: noexpandtab
|
0
config/vim/plugin/pickachu/__init__.py
Normal file
0
config/vim/plugin/pickachu/__init__.py
Normal file
BIN
config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
config/vim/plugin/pickachu/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc
Normal file
BIN
config/vim/plugin/pickachu/__pycache__/apps.cpython-39.pyc
Normal file
Binary file not shown.
BIN
config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc
Normal file
BIN
config/vim/plugin/pickachu/__pycache__/main.cpython-39.pyc
Normal file
Binary file not shown.
BIN
config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc
Normal file
BIN
config/vim/plugin/pickachu/__pycache__/processors.cpython-39.pyc
Normal file
Binary file not shown.
68
config/vim/plugin/pickachu/apps.py
Normal file
68
config/vim/plugin/pickachu/apps.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
import vim
|
||||
import subprocess
|
||||
from . import processors
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# name: apps.py
|
||||
# description: this function contains a dictionary object
|
||||
# where you can easily add new apps with processor
|
||||
# functions to handle their output. Note: a
|
||||
# processor is optional.
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
ZENITY_COMMAND = vim.eval("g:pickachu_default_command")
|
||||
# Note: This is not the final date format that displays on
|
||||
# the users' buffer. This is the format we force
|
||||
# Zenity/Qarma to provide us.
|
||||
RETURNED_DATE_FORMAT = "%m/%d/%Y"
|
||||
if ZENITY_COMMAND == 'qarma':
|
||||
RETURNED_DATE_FORMAT = "MM/dd/yy"
|
||||
|
||||
apps = {
|
||||
'date': {
|
||||
'cmd': ZENITY_COMMAND,
|
||||
'processor': processors.dateProcessor,
|
||||
'options': [
|
||||
'--calendar',
|
||||
'--date-format=' + RETURNED_DATE_FORMAT
|
||||
]
|
||||
},
|
||||
'file': {
|
||||
'cmd': ZENITY_COMMAND,
|
||||
'options': [
|
||||
'--file-selection'
|
||||
]
|
||||
},
|
||||
'color': {
|
||||
'cmd': ZENITY_COMMAND,
|
||||
'options': [
|
||||
'--color-selection'
|
||||
],
|
||||
'processor': processors.colorProcessor
|
||||
}
|
||||
}
|
||||
|
||||
def runApp(choosenApp, format=None):
|
||||
app = apps.get(choosenApp, None)
|
||||
if app:
|
||||
output = None
|
||||
try:
|
||||
command_array = [app['cmd']]
|
||||
if app.get('options', False):
|
||||
for option in app['options']:
|
||||
command_array.append(option)
|
||||
# Logging
|
||||
command_array.append('2> /tmp/pickachu_log')
|
||||
output = subprocess.check_output(command_array).decode('utf-8')
|
||||
except:
|
||||
return None
|
||||
|
||||
if app.get('processor', None):
|
||||
if format:
|
||||
return app['processor'](output.rstrip(), format)
|
||||
else:
|
||||
return app['processor'](output.rstrip())
|
||||
else:
|
||||
return output.rstrip()
|
||||
else:
|
||||
print("App does not exist.")
|
36
config/vim/plugin/pickachu/main.py
Normal file
36
config/vim/plugin/pickachu/main.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import vim
|
||||
from . import apps
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# name: main.py
|
||||
# description: This file evaluates the command arguments
|
||||
# provided by the user, calls the runApp function,
|
||||
# and inserts valid output to the user's buffer.
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
DEFAULT_APP = vim.eval('g:pickachu_default_app')
|
||||
|
||||
|
||||
def MainFunction():
|
||||
# This section is for getting the
|
||||
# arguments from the user's Vim
|
||||
# command.
|
||||
arglength = int(vim.eval('a:0'))
|
||||
CHOOSEN_APP = DEFAULT_APP
|
||||
CHOOSEN_FORMAT = None
|
||||
if arglength > 0:
|
||||
CHOOSEN_APP = vim.eval('a:1')
|
||||
if arglength > 1:
|
||||
CHOOSEN_FORMAT = vim.eval('a:2')
|
||||
|
||||
# We run apps.py's runApp function to get an output.
|
||||
output = apps.runApp(CHOOSEN_APP, CHOOSEN_FORMAT)
|
||||
|
||||
# Now, if runApp gave us an output, we can use the
|
||||
# Vim API to print the output to the user's buffer.
|
||||
if output:
|
||||
pos_y, pos_x = vim.current.window.cursor
|
||||
vim.current.line = vim.current.line[:pos_x+1] + output + vim.current.line[pos_x+1:]
|
||||
vim.current.window.cursor = (pos_y, pos_x + len(output))
|
||||
else:
|
||||
print('Pickachu - Canceled')
|
80
config/vim/plugin/pickachu/processors.py
Normal file
80
config/vim/plugin/pickachu/processors.py
Normal file
|
@ -0,0 +1,80 @@
|
|||
import vim
|
||||
from datetime import datetime
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# name: processors.py
|
||||
# description: this file contains functions that process data
|
||||
# from the runapp function (in app.py).
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
DEFAULT_DATE_FORMAT = vim.eval("g:pickachu_default_date_format")
|
||||
DEFAULT_COLOR_FORMAT = vim.eval("g:pickachu_default_color_format")
|
||||
|
||||
def dateProcessor(input, format=DEFAULT_DATE_FORMAT):
|
||||
try:
|
||||
dateObj = datetime.strptime(input, '%m/%d/%Y')
|
||||
except(ValueError):
|
||||
dateObj = datetime.strptime(input, '%m/%d/%y')
|
||||
return dateObj.strftime(format)
|
||||
|
||||
def colorProcessor(input, format=DEFAULT_COLOR_FORMAT):
|
||||
# The system color picker returned an rgba value
|
||||
if 'rgba' in input:
|
||||
strip = input.strip('rgba)(')
|
||||
array = strip.split(',')
|
||||
# Round the alpha value to two decimal placed
|
||||
array[3] = round(float(array[3]), 2)
|
||||
rgba_string = "rgba("
|
||||
values = ",".join(str(x) for x in array)
|
||||
rgba_string += values + ")"
|
||||
return rgba_string
|
||||
# The system color picker returned an rgb value
|
||||
elif 'rgb' in input:
|
||||
# RGB as input
|
||||
if format == 'rgb':
|
||||
return input
|
||||
else:
|
||||
# Strip 'rgb' and parenthesis
|
||||
strip = input.strip('rgb)(')
|
||||
array = strip.split(',')
|
||||
|
||||
if format == 'hex':
|
||||
hex = '#%02x%02x%02x' % (int(array[0]), int(array[1]), int(array[2]))
|
||||
return hex.upper()
|
||||
elif format == 'rgba':
|
||||
rgba_string = "rgba("
|
||||
array.append(1)
|
||||
values = ",".join(str(x) for x in array)
|
||||
rgba_string += values + ")"
|
||||
return rgba_string
|
||||
return array
|
||||
# The system olor picker returned a hex
|
||||
elif '#' in input:
|
||||
# If there is a '#' in input,
|
||||
# they are most likely using Qarma instead of Zenity
|
||||
# or any other program that outputs hex
|
||||
if format == 'hex':
|
||||
return input
|
||||
else:
|
||||
hex = input.lstrip('#')
|
||||
rgb_array = tuple(int(hex[i:i+2], 16) for i in (0, 2 ,4))
|
||||
|
||||
if format == 'rgb':
|
||||
rgb_string = "rgb("
|
||||
for i in range(0, len(rgb_array)):
|
||||
rgb_string += str(rgb_array[i])
|
||||
if i < len(rgb_array) - 1:
|
||||
rgb_string += ", "
|
||||
else:
|
||||
rgb_string += ")"
|
||||
return rgb_string
|
||||
elif format == 'rgba':
|
||||
rgba_string = "rgba("
|
||||
for i in range(0, len(rgb_array)):
|
||||
rgba_string += str(rgb_array[i])
|
||||
if i < len(rgb_array) - 1:
|
||||
rgba_string += ", "
|
||||
else:
|
||||
rgba_string += ", 1)"
|
||||
return rgba_string
|
||||
return None
|
13
config/vim/plugin/rainbow_parentheses.vim
Normal file
13
config/vim/plugin/rainbow_parentheses.vim
Normal file
|
@ -0,0 +1,13 @@
|
|||
"==============================================================================
|
||||
" Description: Rainbow colors for parentheses, based on rainbow_parenthsis.vim
|
||||
" by Martin Krischik and others.
|
||||
"==============================================================================
|
||||
" GetLatestVimScripts: 3772 1 :AutoInstall: rainbow_parentheses.zip
|
||||
|
||||
com! RainbowParenthesesToggle cal rainbow_parentheses#toggle()
|
||||
com! RainbowParenthesesToggleAll cal rainbow_parentheses#toggleall()
|
||||
com! RainbowParenthesesActivate cal rainbow_parentheses#activate()
|
||||
com! RainbowParenthesesLoadRound cal rainbow_parentheses#load(0)
|
||||
com! RainbowParenthesesLoadSquare cal rainbow_parentheses#load(1)
|
||||
com! RainbowParenthesesLoadBraces cal rainbow_parentheses#load(2)
|
||||
com! RainbowParenthesesLoadChevrons cal rainbow_parentheses#load(3)
|
Loading…
Add table
Add a link
Reference in a new issue