Skip to content

Instantly share code, notes, and snippets.

View hrsh7th's full-sized avatar
🌴
Super busy now. Thank you for sponsors!

hrsh7th hrsh7th

🌴
Super busy now. Thank you for sponsors!
View GitHub Profile
local cmp = require('cmp')
vim.api.nvim_create_user_command('CmpToggle', function()
local config = cmp.get_config()
if config.enabled == false then
cmp.setup { enabled = require('cmp.config.default')().enabled }
else
cmp.setup { enabled = false }
end
end, {})
@hrsh7th
hrsh7th / a.vim
Last active August 27, 2021 11:50
line oriented macro
command! MacroStart call s:command_macro_start()
function! s:command_macro_start() abort
normal! 0qq
endfunction
command! MacroFinish call s:command_macro_finish()
function! s:command_macro_finish() abort
normal! q
endfunction
@hrsh7th
hrsh7th / parallel.lua
Last active October 23, 2022 07:59
neovim lua parallel
-- You can also use require('mpack') for data serialization between server and client.
local uv = require "luv"
local SOCK = string.format("/tmp/server-%s.sock", os.clock())
uv.new_thread(function(sock)
local uv = require "luv"
local server = uv.new_pipe(false)
server:bind(sock)
@hrsh7th
hrsh7th / denite-close.vim
Created January 8, 2021 13:12
denite close
autocmd! vimrc FileType denite-filter call s:setup_denite_filter()
function! s:setup_denite_filter()
imap <silent><nowait><buffer> <Esc> <Plug>(denite_filter_quit)
endfunction
@hrsh7th
hrsh7th / a.lua
Last active December 9, 2020 15:12
sample
local lapi = require'lapi'
local SELECTOR = {
markers = { 'package.json' },
filetypes = { 'javascript', 'typescript', 'javascript.jsx', 'typescript.tsx' },
}
lapi.extensions.register('eslint', {
is = function(document)
@hrsh7th
hrsh7th / vim
Created August 19, 2020 01:29
vsnip bug reproducible vimrc
if has('vim_starting')
set encoding=utf-8
endif
scriptencoding utf-8
if &compatible
" vint: -ProhibitSetNoCompatible
set nocompatible
endif
@hrsh7th
hrsh7th / example.vim
Last active March 8, 2019 08:25
defx close_tree like common file explorer.
autocmd FileType defx call s:defx_setting()
function! s:defx_setting() abort
nnoremap <silent><buffer><expr>h defx#do_action('call', 'DefxCloseTree')
nnoremap <silent><buffer><expr>l defx#is_directory() ? defx#do_action('open_tree') . 'j' : defx#do_action('open', 'edit')
endfunction
function! DefxCloseTree(_)
" candidate is opend tree?
if defx#is_opened_tree()
return defx#call_action('close_tree')
1. gvim を起動
2. .git 管理されているファイルを開く
3. (開いたファイルと同一階層に)「日本語のファイル」というファイル名でファイルを作成する
4. :UniteVersions status:! を実行
5. ステータス一覧が表示されるが「日本語のファイル」が文字化けしている
@hrsh7th
hrsh7th / gist:3781400
Created September 25, 2012 12:10
my quickrun x watchdogs x hier vimrc.
let g:quickrun_config = {}
let g:quickrun_config['watchdogs_checker/_'] = {
\ 'hook/close_quickfix/enable_exit': 1,
\ }
let g:watchdogs_check_BufWritePost_enable=1
call watchdogs#setup(g:quickrun_config)
let s:save_cpo = &cpo
set cpo&vim
function! unite#sources#my_file_rec#define()
return s:source
endfunction
let s:source = {
\ 'name': 'my/file_rec',
\ 'description': 'my files.'