Skip to content

Instantly share code, notes, and snippets.

@h-michael
h-michael / main.tf
Created October 26, 2020 04:10
use google_project_iam_member as setting roles for grouped members
locals {
role_map_list = flatten([
for role in var.roles : [
for member in var.members : {
role : role,
member : member
}
]
])
}
callbacks = vim.lsp.callbacks
callbacks['textDocument/publishDiagnostics'] = function(_, _, result)
if not result then return end
local uri = result.uri
local bufnr = vim.uri_to_bufnr(uri)
if not bufnr then
err_message("LSP.publishDiagnostics: Couldn't find buffer for ", uri)
return
end
util.buf_clear_diagnostics(bufnr)

Keybase proof

I hereby claim:

  • I am h-michael on github.
  • I am hmichael (https://keybase.io/hmichael) on keybase.
  • I have a public key whose fingerprint is E96C A003 DD49 28EC 567B 52FC CB35 EEF3 02FE D462

To claim this, I am signing this object:

$ nvim --version
NVIM v0.5.0-366-g932949229
$ ra_lsp_server
rust-analyzer 759100f
```
[ INFO ] 2020-02-12T17:11:02Z+0900 ] .../h-michael/.local/share/nvim/runtime/lua/vim/lsp/rpc.lua:204 ] "Starting RPC client" { args = {}, cmd = "ra_lsp_server", extra = {}}
[ DEBUG ] 2020-02-12T17:11:02Z+0900 ] /home/h-michael/.local/share/nvim/runtime/lua/vim/lsp.lua:486 ] "LSP[rust_analyzer]" "initialize_params" { capabilities = { textDocument = { completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = false }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 } }, contextSupport = false, dynamicRegistration = false }, documentHighlight = { dynamicRegistration = false }, documentSymbo
@h-michael
h-michael / luaheredoc.vim
Last active January 2, 2020 06:49
lua in vimrc with heredoc
" OK
if v:true
lua << EOF
local foo = 'foo'
EOF
endif
" NG
if v:true
lua << EOF
@h-michael
h-michael / lsp_test.vim
Created October 29, 2019 03:49
minimal vimrc for testing lsp
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'Shougo/deoplete.nvim'
Plug 'Shougo/deoplete-lsp'
call plug#end()
@h-michael
h-michael / lsp_test.vim
Created October 29, 2019 03:49
minimal vimrc for testing lsp
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'Shougo/deoplete.nvim'
Plug 'Shougo/deoplete-lsp'
call plug#end()
@h-michael
h-michael / validator.lua
Last active October 27, 2019 08:08
simple function arguments type check function
local function type_check(...)
local function type_name(t)
assert(type(t) == 'string')
if t == 't' or t == 'table' then return 'table' end
if t == 's' or t == 'string' then return 'string' end
if t == 'n' or t == 'number' then return 'number' end
if t == 'b' or t == 'boolean' then return 'boolean' end
if t == 'f' or t == 'function' then return 'f' end
if t == 'nil' then return 'nil' end
@h-michael
h-michael / adp_macro.rs
Created May 1, 2019 09:13
build adp definitions macro sample
macro_rules! _adp_denitition {
($($doc_comment: literal)*, $enum_name:ident, $trait_name:ident, $type_ident:ident, $(($type_name:ident, $type_definition:ident),)*) => {
$(#[doc=$doc_comment])*
#[derive(Debug)]
pub enum $enum_name {}
impl $trait_name for $enum_name {
$(type $type_name = $type_definition;)*
const $type_ident: &'static str = stringify!(stringify!($enum_name).to_lowercase());
}
@h-michael
h-michael / query.graphql
Last active December 9, 2018 02:20
generate wrong fragment with union type
fragment custom_actor on Actor {
__typename
... on User {
id
name
login
}
... on Organization {
id
name