Giter Site home page Giter Site logo

vim-lsp's Introduction

vim-lsp

Async Language Server Protocol plugin for vim8 and neovim.

Installing

Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'

Note: async.vim is required and is used to normalize jobs between vim8 and neovim.

Registering servers

For other languages please refer to the wiki.

if executable('pyls')
    " pip install python-language-server
    au User lsp_setup call lsp#register_server({
        \ 'name': 'pyls',
        \ 'cmd': {server_info->['pyls']},
        \ 'whitelist': ['python'],
        \ })
endif

While most of the time it is ok to just set the name, cmd and whitelist there are times when you need to get more control of the root_uri. By default root_uri for the buffer can be found using lsp#utils#get_default_root_uri() which internaly uses getcwd(). Here is an example that sets the root_uri to the directory where it contains tsconfig.json and traverses up the directories automatically, if it isn't found it returns empty string which tells vim-lsp to start the server but don't initialize the server. If you would like to avoid starting the server you can return empty array for cmd.

if executable('typescript-language-server')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'typescript-language-server',
        \ 'cmd': {server_info->[&shell, &shellcmdflag, 'typescript-language-server', '--stdio']},
        \ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'tsconfig.json'))},
        \ 'whitelist': ['typescript'],
        \ })
endif

auto-complete

vim-lsp by default only provides basic omnifunc support for autocomplete. Completion can be made asynchronous by setting g:lsp_async_completion. Note that this may cause unexpected behavior in some plugins such as MUcomplete.

If you would like to have more advanced features please use asyncomplete.vim as described below.

omnifunc

" let g:lsp_async_completion = 1

autocmd FileType typescript setlocal omnifunc=lsp#complete

asyncomplete.vim

asyncomplete.vim is a async auto complete plugin for vim8 and neovim written in pure vim script without any python dependencies.

Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'

Supported commands

Note:

  • Some servers may only support partial commands.
  • While it is possible to register multiple servers for the same filetype, some commands will pick only pick the first server that supports it. For example, it doesn't make sense for rename and format commands to be sent to multiple servers.
Command Description
:LspDocumentDiagnostics Get current document diagnostics information
:LspDefinition Go to definition
:LspDocumentFormat Format entire document
:LspDocumentRangeFormat Format document selection
:LspDocumentSymbol Show document symbols
:LspHover Show hover information
:LspReferences Find references
:LspRename Rename symbol
:LspWorkspaceSymbol Search/Show workspace symbol

Debugging

In order to enable file logging set g:lsp_log_file.

let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/vim-lsp.log')

" for asyncomplete.vim log
let g:asyncomplete_log_file = expand('~/asyncomplete.log')

vim-lsp's People

Contributors

djrenren avatar keremc avatar mlen avatar prabirshrestha avatar tsufeki avatar

Watchers

 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.