Coder Social home page Coder Social logo

devdocs.vim's Introduction

devdocs.vim

Build Status

This is a Vim plugin for devdocs, which is an awesome multiple API documentation service. You can open and search devdocs from Vim.

  • Open and search devdocs using command :DevDocs or :DevDocsAll
  • Relate filetype to specific documentation.
  • Search word under the cursor.

Usage

  • :DevDocs [query] : Search with query with filetype related documentation (query can be omitted)
  • :DevDocsAll [query] : Search with query with all documentation (query can be omitted)

Customize

Mapping K to search under the word quickly

devdocs.vim doesn't overrides any mapping by default. You should define key mappings if you need.

If you always want to override K mapping,

nmap K <Plug>(devdocs-under-cursor)

If you want to override K mapping in specific filetypes,

augroup plugin-devdocs
  autocmd!
  autocmd FileType c,cpp,rust,haskell,python nmap <buffer>K <Plug>(devdocs-under-cursor)
augroup END

Above replaces K in C, C++, Rust, Haskell, and Python.

Open with specific documentation on specific filetype

You can customize relationship between Vim's filetype and documentation. Below is an example of customization.

let g:devdocs_filetype_map = {
    \   'ruby': 'rails',
    \   'javascript.jsx': 'react',
    \   'javascript.test': 'chai',
    \ }

With above configuration, :DevDocs blah searches Rails documentation on filetype ruby.

:DevDocsAll searches all documentation ignoring filetype relation and below configuration explicitly disables this feature.

let g:devdocs_filetype_map = { '*': '' }

Open local devdocs

You can easily host local devdocs. If your local devdocs is hosted at localhost:9292, devdocs.vim uses it by following configuration.

let g:devdocs_host = 'localhost:9292'

If you use http:// to host your DevDocs instance, please use g:devdocs_url variable to specify an http:// scheme.

let g:devdocs_url = 'http://localhost:9292'

Make a command for specific document

You can use devdocs#open_doc() function to make such a command.

Below is an example for :DevDocsReact command to open page with 'react' documentation

command! -nargs=* DevDocsReact call devdocs#open_doc(<q-args>, 'react')

You can execute as below,

:DevDocsReact
:DevDocsReact componentDidMount

Open in non-default browser

devdocs.vim opens URL with open-browser.vim at first. If it is not installed, it tries to open default browser. If you don't install open-browser.vim and want to use non-default browser, please use g:devdocs_open_cmd to specify what command should be used for opening a browser.

" Open devdocs.io in Safari on macOS
let g:devdocs_open_cmd = 'open -a Safari'

" Open devdocs.io in Firefox on Linux
let g:devdocs_open_cmd = 'firefox'

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.

devdocs.vim's People

Contributors

castellafactory avatar cww0614 avatar deris avatar rhysd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

devdocs.vim's Issues

Error on opening URL in Win10

image

处理 function devdocs#open[5]..<SNR>78_open_fallback 时发生错误:
第  18 行:
Error on opening URL: 'http://devdocs.io/#q=Long'

System: Win10
Vim: 8.0

A workaround for me:

change autoload/devdocs.vim#line39 from

call system('cmd /q /c start "" ' . url)

to

call system('cmd /q /c start "" ' . substitute(url, "'", "", "g"))

Open Window/Tab With Result

Hey!
As I found this here, I was heavily breathing. Then I realized, that it opens the search result in the web browser and not in Vim. Thats nice, but could be better (couldn't it?).
So what do u think about the idea to grep the resulting webpage (wget is enough I assume), convert this page into markdown (some nice converters are out there) and display this temporally file (/tmp/...) in a new window/tab (configurable). Thinking further it would be useful if the window with the last search result stays open and the user starts a new search, the window is reused.
Links in the page for further results can be opened as normal and then the browser will be opened (should be easier so far). I'm thinking about something like this here.
Good? Bad? Awesome! Horrible...

Search on multiple docs

Would be nice be possible to search on multiple docs, with some config like:

let g:devdocs_filetype_map = {
    \   'elixir': ['elixir','phoenix'],
\ }

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.