GithubHelp home page GithubHelp logo

tkoyama010 / nyaovim-mini-browser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rhysd/nyaovim-mini-browser

0.0 2.0 0.0 9 KB

Embedded Mini Browser for NyaoVim

Home Page: https://github.com/rhysd/NyaoVim

HTML 92.07% Vim Script 7.93%

nyaovim-mini-browser's Introduction

Inner Mini Browser for NyaoVim

This is NyaoVim UI plugin to open an embedded browser in window. This is implemented as Web Component and built on Electron's webview.

screenshot

Installation

Install this repository as Vim plugin with your favorite plugin manager. And put <mini-browser> component to your nyaovimrc.html as below.

<style>
  /* CSS configurations here */
  .horizontal {
    display: flex;
    width: 100%;
    height: 100%;
  }
  neovim-editor {
    width: 100%;
    height: 100%;
  }
</style>

<!-- Put your component in flex box layout  -->
<div class="horizontal">
  <neovim-editor id="nyaovim-editor" argv$="[[argv]]"></neovim-editor>
  <mini-browser editor="[[editor]]"></mini-browser>
</div>

This is a setting example. You can put <mini-browser> component as you like.

Commands

  • :MiniBrowser [url]: Open mini browser with specified URL. If url is omitted, previous page is shown. If you add ! to the command, focus doesn't move after opening a browser.
  • :MiniBrowserClose: Close mini browser.

Keymaps In Browser

keymap description
j Scroll half page down
k Scroll half page up
h Scroll half page left
l Scroll half page right
Ctrl+x Close mini browser
Ctrl+Shift+f Page goes forward
Ctrl+Shift+b Page goes back
Ctrl+r Reload page
Ctrl+Shift+i Open DevTools window

Extend Your Usage

This plugin only provides very simple commands. You can write script to extend your usage with the commands as below.

  • Open GitHub issues of current repository
  • Look for a word under the cursor in online documentations
  • Search something on Google Search
  • Play music on SoundCloud ;)
  • etc...

Example1: Open URL under cursor

If you want to open a URL under cursor, adding below mapping to init.vim will help you. Mapping to <Leader>o is an example. You can map it to your favorite key sequence.

nnoremap <Leader>o :<C-u>MiniBrowser <C-r><C-p><CR>

Example2: devdocs.io

Below is an example configuration to search devdocs.io instantly. :Devdocs command is defined. When parameter is given, it opens devdocs.io with the parameter as query. If no parameter is given, it opens devdocs.io with the word under cursor.

function! s:devdocs(query) abort
    if a:query ==# ''
        let cword = expand('<cword>')
        if cword ==# ''
            MiniBrowser http://devdocs.io/
        else
            execute 'MiniBrowser' 'http://devdocs.io/#q='.escape(cword, ' \')
        endif
        return
    endif

    execute 'MiniBrowser' 'http://devdocs.io/#q='.escape(a:query, ' \')
endfunction
command! -nargs=* DevDocs call <SID>devdocs(<q-args>)

Properties of <mini-browser>

You can specify url, width, useragent, and visible to the tag.

<mini-browser
  url="https://google.com"
  width="600"
  useragent="...(snip)"
  visible
></mini-browser>

License

Copyright (c) 2015 rhysd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nyaovim-mini-browser's People

Contributors

rhysd avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.