Skip to content

Instantly share code, notes, and snippets.

@nelstrom
Created October 17, 2017 17:20
Show Gist options
  • Save nelstrom/d677474c8e71baa3b4b72f24b66f94f0 to your computer and use it in GitHub Desktop.
Save nelstrom/d677474c8e71baa3b4b72f24b66f94f0 to your computer and use it in GitHub Desktop.
Specifying project-local indentation settings via Projectionist
{
"*.js": {
"indent": "tabs:3"
}
}
autocmd User ProjectionistActivate call s:activate()
function! s:activate() abort
for [root, value] in projectionist#query('indent')
let l:pattern = '\v(tabs|spaces):(\d)'
let l:matches = matchlist(value, l:pattern)
if !empty(l:matches)
let l:type = l:matches[1]
let l:size = l:matches[2]
if l:type ==? 'spaces'
setlocal expandtab
endif
if l:type ==? 'tabs'
setlocal noexpandtab
endif
let &l:tabstop = l:size
let &l:softtabstop = l:size
let &l:shiftwidth = l:size
endif
break
endfor
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment