nvim --api-info
to dump the api info in msgpack formatnvim --api-info | python -c 'import msgpack, sys, yaml; print yaml.dump(msgpack.unpackb(sys.stdin.read()))'
error_types:
Exception: {id: 0}
Validation: {id: 1}
functions:
- async: false
can_fail: true
name: buffer_line_count
parameters:
- [Buffer, buffer]
return_type: Integer
NVIM_LISTEN_ADDRESS
NVIM_LISTEN_ADDRESS=/tmp/nvim nvim
NVIM_LISTEN_ADDRESS=/tmp/nvim stack ghci
λ Right (tids, cfg) <- develMain Nothing
λ runNeovim' cfg $ vim_call_function "getqflist" []
Right (Right (ObjectArray []))
Make a shell script and put the stack exec
in it
PATH=`stack path --bin-path` stack exec nvim-hs-emoji-exe -- "$@"
rpcstart
function callremote#host#Register
and remote#host#Reqreui
are VimL help function
if has('nvim') " This way you can also put it in your vim config file
call remote#host#Register('fibonacci', "*", rpcstart('/Users/mno2/Develop/haskell/nvim-fib/nvim-hs-devel.sh'))
let haskellChannel = remote#host#Require('fibonacci')
if haskellChannel < 1
echom 'Failure to initialize the haskell channel for remote procedure calls'
cq!
endif
endif
N
under the cursor, calculate the N
th Fibonacci number.Neovim
monad, which is data Neovim r st a
module Fibonacci.Plugin (fibonacci) where
import Neovim
fibonacci :: Neovim r st String
fibonacci = do
cw <- errOnInvalidResult $ vim_call_function "expand" $ [toObject "<cword>"]
let n = read cw
return $ show (fibs !! n)
where
fibs :: [Integer]
fibs = 0:1:scanl1 (+) fibs
omnifunc
mechanism for autocompletionCtrl-X Ctrl-O
findstart
and base
findstart
as 1 and base
as emptyfindstart
as 0 and base
as the prefixemojicomplete :: Bool -> String -> Neovim r st (Either Int [String])
emojicomplete findstart base = do
if findstart
then do
curr_line :: String <- errOnInvalidResult $ vim_call_function "getline" $ [toObject "."]
curr_col :: Int <- errOnInvalidResult $ vim_call_function "col" $ [toObject "."]
let prefix = take (curr_col-1) curr_line
let reverse_idx = fromMaybe 0 (L.findIndex (== ' ') (reverse prefix))
return $ Left (curr_col - reverse_idx - 1)
else do
let emoji = [":thumbsup:", ":thumbsdown:", ":smile:", ":banana:"]
let ans = filter (L.isPrefixOf base) emoji
return $ Right ans