From f3a5b6f53ee102eec178f1eefb14496a1b59e4d0 Mon Sep 17 00:00:00 2001 From: daa84 Date: Sun, 21 May 2017 17:27:05 +0300 Subject: [PATCH 1/4] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e34a64f..e8540e9 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,16 @@ cargo run -- --nvim-bin-path=E:\Neovim\bin\nvim.exe cargo run -- --enable-external-popup ``` # Install +## From sources +By default to `/usr/local`: +``` +make install +``` +Or to some custom path: +``` +make PREFIX=/some/custom/path install +``` + ## Ubuntu snap package Not usable for now due to some limitation! From c16f70ac1d4a40a887ef771478d68c94f55dfbf6 Mon Sep 17 00:00:00 2001 From: daa Date: Sun, 21 May 2017 17:28:07 +0300 Subject: [PATCH 2/4] Update install script --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a091a78..3d2b792 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,7 @@ run: RUST_BACKTRACE=1 cargo run install: install-resources - mkdir -p $(PREFIX)/bin/ - cp target/release/nvim-gtk $(PREFIX)/bin/ + cargo install --root $(PREFIX) install-resources: mkdir -p $(PREFIX)/share/applications/ From 64c5fb114741b83b672a1b89a21006292ff1ec96 Mon Sep 17 00:00:00 2001 From: daa Date: Wed, 24 May 2017 14:00:23 +0300 Subject: [PATCH 3/4] Add neovim-qt compatible layer (#5) Add shim to rtp, add gtk gui flag --- Makefile | 2 ++ runtime/plugin/nvim_gui_shim.vim | 45 ++++++++++++++++++++++++++++++++ src/nvim.rs | 14 ++++++++++ 3 files changed, 61 insertions(+) create mode 100644 runtime/plugin/nvim_gui_shim.vim diff --git a/Makefile b/Makefile index 3d2b792..e5b2b56 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ install: install-resources cargo install --root $(PREFIX) install-resources: + mkdir -p $(PREFIX)/share/nvim-gtk/ + cp -r runtime $(PREFIX)/share/nvim-gtk/ mkdir -p $(PREFIX)/share/applications/ cp desktop/nvim-gtk.desktop $(PREFIX)/share/applications/ mkdir -p $(PREFIX)/share/icons/hicolor/128x128/apps/ diff --git a/runtime/plugin/nvim_gui_shim.vim b/runtime/plugin/nvim_gui_shim.vim new file mode 100644 index 0000000..8e48dbe --- /dev/null +++ b/runtime/plugin/nvim_gui_shim.vim @@ -0,0 +1,45 @@ +" A Neovim plugin that implements GUI helper commands +if !has('nvim') || exists('g:GuiLoaded') + finish +endif +let g:GuiLoaded = 1 + +" Set GUI font +function! GuiFont(fname, ...) abort + call rpcnotify(1, 'Gui', 'Font', s:NvimQtToPangoFont(a:fname)) +endfunction + +" Some subset of parse command from neovim-qt +" to support interoperability +function s:NvimQtToPangoFont(fname) + let l:attrs = split(a:fname, ':') + let l:size = -1 + for part in l:attrs + if len(part) >= 2 && part[0] == 'h' + let l:size = strpart(part, 1) + endif + endfor + + if l:size > 0 + return l:attrs[0] . ' ' . l:size + endif + + return l:attrs[0] +endf + + +" The GuiFont command. For compatibility there is also Guifont +function s:GuiFontCommand(fname, bang) abort + if a:fname ==# '' + if exists('g:GuiFont') + echo g:GuiFont + else + echo 'No GuiFont is set' + endif + else + call GuiFont(a:fname, a:bang ==# '!') + endif +endfunction +command! -nargs=? -bang Guifont call s:GuiFontCommand("", "") +command! -nargs=? -bang GuiFont call s:GuiFontCommand("", "") + diff --git a/src/nvim.rs b/src/nvim.rs index acef1d8..ba90e07 100644 --- a/src/nvim.rs +++ b/src/nvim.rs @@ -1,4 +1,5 @@ use std::io::{Result, Error, ErrorKind}; +use std::env; use std::process::{Stdio, Command}; use std::result; use std::sync::Arc; @@ -82,8 +83,21 @@ pub fn initialize(shell: Arc>, .arg("--headless") .arg("--cmd") .arg("set termguicolors") + .arg("--cmd") + .arg("let g:GtkGuiLoaded = 1") .stderr(Stdio::inherit()); + if let Ok(runtime_path) = env::var("NVIM_GTK_RUNTIME_PATH") { + cmd.arg("--cmd") + .arg(format!("let &rtp.=',{}'", runtime_path)); + } + else if let Some(prefix) = option_env!("PREFIX") { + cmd.arg("--cmd") + .arg(format!("let &rtp.=',{}/share/nvim-gtk/runtime'", prefix)); + } else { + cmd.arg("--cmd").arg("let &rtp.=',runtime'"); + } + let session = Session::new_child_cmd(&mut cmd); let session = match session { From 7f6efe5befdb869c214dccc40d722533ef4c7cd8 Mon Sep 17 00:00:00 2001 From: daa84 Date: Wed, 24 May 2017 16:32:01 +0300 Subject: [PATCH 4/4] Update README.md --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e8540e9..f7cb179 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,12 @@ GTK ui for neovim written in rust using gtk-rs bindings. ![Main Window](/screenshots/neovimgtk-screen.png?raw=true) For more screenshots and description of basic usage see [wiki](https://github.com/daa84/neovim-gtk/wiki/GUI) -# Font settings -By default gnome settings are used: -```bash -gsettings get org.gnome.desktop.interface monospace-font-name -``` -To setup font add next line to *ginit.vim* +# Configuration +To setup font add next line to `ginit.vim` ```vim call rpcnotify(1, 'Gui', 'Font', 'DejaVu Sans Mono 12') ``` +for more details see [wiki](https://github.com/daa84/neovim-gtk/wiki/Configuration) # Command line * pass nvim custom execution path (by default used `nvim` command)