Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add buffer-local version of g:ghcmod_ghc_options

  • Loading branch information...
commit 7cc23b1fe7f882987f3b270f7c3b1df6d996689d 1 parent a7c64c0
Kohei Suzuki authored
Showing with 37 additions and 3 deletions.
  1. +12 −0 README.md
  2. +8 −3 autoload/ghcmod.vim
  3. +17 −0 doc/ghcmod.txt
12 README.md
View
@@ -27,6 +27,18 @@ If you'd like to give GHC options, set `g:ghcmod_ghc_options`.
let g:ghcmod_ghc_options = ['-idir1', '-idir2']
~~~
+Also, there's buffer-local version `b:ghcmod_ghc_options`.
+
+~~~vim
+autocmd BufRead,BufNewFile ~/.xmonad/* call s:add_xmonad_path()
+function! s:add_xmonad_path()
+ if !exists('b:ghcmod_ghc_options')
+ let b:ghcmod_ghc_options = []
+ endif
+ call add(b:ghcmod_ghc_options, '-i' . expand('~/.xmonad/lib'))
+endfunction
+~~~
+
### :GhcModType, :GhcModTypeClear
Type `:GhcModType` on a expression, then the sub-expression is highlighted and its type is echoed.
If you type `:GhcModType` multiple times, the sub-expression changes.
11 autoload/ghcmod.vim
View
@@ -437,9 +437,14 @@ function! ghcmod#build_command(args)"{{{
endif
endif
- " Taking the -fno-code flag here results in a *massive* speed increase.
- " Overrideable by the user setting g:ghcmod_ghc_options themselves.
- for l:opt in get(g:, 'ghcmod_ghc_options', ["-fno-code"])
+ if exists('b:ghcmod_ghc_options')
+ let l:opts = b:ghcmod_ghc_options
+ else
+ " Taking the -fno-code flag here results in a *massive* speed increase.
+ " Overrideable by the user setting g:ghcmod_ghc_options themselves.
+ let l:opts = get(g:, 'ghcmod_ghc_options', ["-fno-code"])
+ endif
+ for l:opt in l:opts
call extend(l:cmd, ['-g', l:opt])
endfor
call extend(l:cmd, a:args)
17 doc/ghcmod.txt
View
@@ -108,6 +108,23 @@ g:ghcmod_ghc_options *g:ghcmod_ghc_options*
let g:ghcmod_ghc_options = []
<
+b:ghcmod_ghc_options *b:ghcmod_ghc_options*
+ Buffer-local version of |g:ghcmod_ghc_options|. When both
+ |b:ghcmod_ghc_options| and |g:ghcmod_ghc_options| are defined,
+ |b:ghcmod_ghc_options| is given preference and |g:ghcmod_ghc_options|
+ is ignored.
+
+ Example: adding ~/.xmonad/lib when editing XMonad configs.
+>
+ autocmd BufRead,BufNewFile ~/.xmonad/* call s:add_xmonad_path()
+ function! s:add_xmonad_path()
+ if !exists('b:ghcmod_ghc_options')
+ let b:ghcmod_ghc_options = []
+ endif
+ call add(b:ghcmod_ghc_options, '-i' . expand('~/.xmonad/lib'))
+ endfunction
+<
+
g:ghcmod_hlint_options *g:ghcmod_hlint_options*
Pass these options to hlint. By default, ghcmod doesn't pass any GHC
options.
Please sign in to comment.
Something went wrong with that request. Please try again.