forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add init.vim * Add dune file to copy init.vim * Set up init vim loading * Add simple logger * Use logging API * Augment logging * Parse oni_plugin_notify messages * Formatting
- Loading branch information
Showing
8 changed files
with
162 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(install | ||
(section bin) | ||
(package Oni2) | ||
(files init.vim)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
" init.vim | ||
" Entry point for Oni interop | ||
" Sets defaults for Oni2, and wires up some RPC for autocmds | ||
|
||
if exists("g:loaded_oni_interop_plugin") | ||
finish | ||
endif | ||
|
||
set hidden | ||
set nocursorline | ||
set nobackup | ||
set nowritebackup | ||
set noswapfile | ||
|
||
syntax off | ||
|
||
let g:loaded_oni_interop_plugin = 1 | ||
|
||
function OniNotify(args) | ||
call rpcnotify(1, "oni_plugin_notify", a:args) | ||
endfunction | ||
|
||
function OniNotifyAutocmd(eventName) | ||
let context = OniGetContext() | ||
call OniNotify(["autocmd", a:eventName, context]) | ||
endfunction | ||
|
||
augroup OniEventListeners | ||
autocmd! | ||
autocmd! BufWritePre * :call OniNotifyAutocmd("BufWritePre") | ||
autocmd! BufWritePost * :call OniNotifyAutocmd("BufWritePost") | ||
autocmd! BufEnter * :call OniNotifyAutocmd("BufEnter") | ||
autocmd! BufRead * :call OniNotifyAutocmd("BufRead") | ||
autocmd! BufWinEnter * :call OniNotifyAutocmd("BufWinEnter") | ||
autocmd! BufDelete * :call OniNotifyAutocmd("BufDelete") | ||
autocmd! BufUnload * :call OniNotifyAutocmd("BufUnload") | ||
autocmd! BufWipeout * :call OniNotifyAutocmd("BufWipeout") | ||
autocmd! CursorMoved * :call OniNotifyAutocmd("CursorMoved") | ||
autocmd! CursorMovedI * :call OniNotifyAutocmd("CursorMovedI") | ||
augroup END | ||
|
||
function OniGetContext() | ||
let bufferNumber = bufnr("%") | ||
let line = line(".") | ||
let column = col(".") | ||
|
||
let context = [bufferNumber, line, column] | ||
|
||
return context | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Log.re | ||
* | ||
* Simple console logger | ||
*/ | ||
|
||
let isDebugLoggingEnabled = | ||
switch (Sys.getenv_opt("ONI2_DEBUG")) { | ||
| Some(_) => true | ||
| _ => false | ||
}; | ||
|
||
let info = msg => print_endline("[INFO] " ++ msg); | ||
|
||
let debug = msg => | ||
isDebugLoggingEnabled ? print_endline("[DEBUG] " ++ msg) : (); | ||
|
||
let error = msg => prerr_endline("[ERROR] " ++ msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters