Documentation

Use the Flux LSP with Vim

Flux-LSP no longer maintained

The flux-lsp Flux Language Server Protocol plugin is no longer maintained. The flux-lsp repo has been archived and is no longer receiving updates.

Requirements

Install the Flux plugin

There are many ways to install and manage Vim plugins. We recommend either of the following two methods:

Both methods require you to add the following to your .vimrc so that Vim can recognize the .flux file type:

" Flux file type
au BufRead,BufNewFile *.flux		set filetype=flux
  • Copy
  • Fill window

Install with vim-lsp

  1. Install flux-lsp-cli with npm

    npm i -g @influxdata/flux-lsp-cli
    
    • Copy
    • Fill window
  2. Install vim-lsp

    If it doesn’t exist yet, create a directory called pack/$USER/start/ in your ~/.vim/ and clone vim-lsp into it:

    cd ~
    mkdir -p .vim/pack/$USER/start/
    cd .vim/pack/$USER/start/
    git clone https://github.com/prabirshrestha/vim-lsp
    
    • Copy
    • Fill window
  3. Edit your .vimrc

    Next, edit your .vimrc configuration file to include the following:

    let g:lsp_diagnostics_enabled = 1
    
    if executable('flux-lsp')
        au User lsp_setup call lsp#register_server({
            \ 'name': 'flux lsp',
            \ 'cmd': {server_info->[&shell, &shellcmdflag, 'flux-lsp']},
            \ 'whitelist': ['flux'],
            \ })
    endif
    
    autocmd FileType flux nmap gd <plug>(lsp-definition)
    
    • Copy
    • Fill window

Install with vim-coc

  1. Install flux-lsp-cli from npm

    npm i -g @influxdata/flux-lsp-cli
    
    • Copy
    • Fill window
  2. Install plug-vim

    Install plug-vim, a plugin manager for Vim.

  3. Install vim-coc

    Install vim-coc, a code-completion plugin for Vim.

  4. Configure vim-coc

    vim-coc uses a coc-settings.json located in your ~/.vim/ directory. To run the Flux LSP, add the Flux section under languageserver:

    {
      "languageserver": {
          "flux": {
            "command": "flux-lsp",
            "filetypes": ["flux"]
          }
      }
    }
    
    • Copy
    • Fill window

    To debug flux-lsp, configure it to log to /tmp/fluxlsp:

    {
      "languageserver": {
          "flux": {
            "command": "flux-lsp",
            "args": ["-l", "/tmp/fluxlsp"],
            "filetypes": ["flux"]
          }
      }
    }
    
    • Copy
    • Fill window

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

Now Generally Available

InfluxDB 3 Core and Enterprise

Start fast. Scale faster.

Get the Updates

InfluxDB 3 Core is an open source, high-speed, recent-data engine that collects and processes data in real-time and persists it to local disk or object storage. InfluxDB 3 Enterprise builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries and optimized storage. A free tier of InfluxDB 3 Enterprise is available for non-commercial at-home or hobbyist use.

For more information, check out: