Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

FUJIWARA Takuya tyru

🏠
Working from home
Block or report user

Report or block tyru

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tyru
tyru / require.vim
Last active Jul 2, 2019
require() function for deeply nested very loooooooooong named autoload function
View require.vim
let s:L = vital#of('vital').import('Data.List')
function! s:require(ns, ...) abort
let ns = strtrans(a:ns)
let fnlist = map(
\ split(execute('function /' . ns), '\n'),
\ {_,l -> matchstr(l, '^function ' . ns . '#\zs\w\+\ze(')}
\)
call filter(fnlist, '!empty(v:val)')
if a:0
@tyru
tyru / search-decl-php-ftplugin-2.patch
Last active Jun 6, 2019
Searching declaration in PHP ftplugin (Fix [[, ]] mappings problems, added [], ][ mappings)
View search-decl-php-ftplugin-2.patch
--- php.vim.bak 2018-10-10 14:08:25.875669800 +0900
+++ php.vim 2018-10-10 14:04:30.777334700 +0900
@@ -61,15 +61,107 @@
setlocal omnifunc=phpcomplete#CompletePHP
endif
-" Section jumping: [[ and ]] provided by Antony Scriven <adscriven at gmail dot com>
-let s:function = '\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function'
-let s:class = '\(abstract\s\+\|final\s\+\)*class'
+" Section jumping: [[ and ]] provided by:
@tyru
tyru / run.gs
Last active Mar 21, 2019
Google Apps Script で Gmail の添付ファイルを Google Drive に保存
View run.gs
// Google Drive でフォルダに移動した時のURLで分かる
// https://drive.google.com/drive/u/1/folders/{フォルダのID}
var SAVE_FOLDER_ID = 'フォルダのID';
var READ_LABEL_NAME = '添付ファイル保存済み';
var SEARCH_CONDITION = 'has:attachment -label:' + READ_LABEL_NAME;
var THREADS_PER_PAGE = 100;
function saveAttachments() {
Logger.clear();
Logger.log('start');
View flatten.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef enum _type_t {
INT_T,
STRING_T,
LIST_T,
} type_t;
View vimrc
set laststatus=2
let &statusline = '%!StatusLine()'
function! StatusLine() abort
if &hlsearch
" XXX: 'l', 'h' do not move current cursor!
let searchcount = matchstr(execute('keepjumps keepmarks %s//&/gne', 'silent'), '\d\+')
let searchcount = printf(' (%s/%s)', searchcount !=# '' ? searchcount : '0', @/)
else
let searchcount = ''
View execute-convert-snr.patch
diff --git a/src/eval.c b/src/eval.c
index 4a3cf9912..cdb1d2f4e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -8109,6 +8109,7 @@ ex_echohl(exarg_T *eap)
ex_execute(exarg_T *eap)
{
char_u *arg = eap->arg;
+ char_u *trans_arg;
typval_T rettv;
@tyru
tyru / sid_snr.vim
Last active Nov 11, 2018
Bizarre <SID> and <SNR> conversion (https://github.com/vim-jp/issues/issues/1201)
View sid_snr.vim
function! s:get_next_tab(n) abort
let last = tabpagenr('$')
let i = (tabpagenr() - 1 + a:n) % last
let i = i < 0 ? last + i : i
return i ==# 0 || i + 2 ==# tabpagenr() ? i : i + 1
endfunction
" =============== Error ===============
@tyru
tyru / vimrc.vim
Created Oct 10, 2018
Toggle current tab's terminal window modes
View vimrc.vim
nnoremap <Plug>(vimrc:prefix:excmd)oT :<C-u>call <SID>toggle_terminal_modes()<CR>
function! s:toggle_terminal_modes()
let prevwinnr = winnr()
" -1: undefined, 0: terminal normal mode, 1: terminal job mode
" Change all terminal window's modes to this mode.
" It is determined by the first terminal window's mode.
let dest_mode = -1
try
for bufnr in tabpagebuflist()
@tyru
tyru / output
Last active Sep 23, 2018
Parsing / Evaluating Vim script number literals in Prolog DCG
View output
number(tInt(['1']))
number(tFloat(int_flac(['1'],['0'])))
number(tInt(['1','2','3','4','5','6','7','8','9']))
number(tFloat(int_flac(['1','2'],['3','4'])))
number(tInt(bin('0b',['1','0','1','0'])))
number(tInt(bin('0B',['0','1','0','1'])))
number(tInt(hex('0x',['D',e,'A',d,'B',e,'E',f])))
number(tInt(hex('0X',[d,'E',a,'D',b,'E',e,'F'])))
number(tInt(hex('0x',['1','2','3','4','5','6','7','8','9',a,b,c,d,e,f,'A','B','C','D','E','F'])))
number(tInt(hex('0X',['1','2','3','4','5','6','7','8','9',a,b,c,d,e,f,'A','B','C','D','E
View duptermbuf.vim
scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim
" index = xterm number
" cf.
" * :help cterm-colors
" * https://jonasjacek.github.io/colors/
let s:color_table = [
You can’t perform that action at this time.