SuperBOL plugin for Vim/Neovim

Warning

You have to build the SuperBOL Studio binary first. See: How to build the SuperBOL Studio binary.

Install for Vim

Coc

You can add the SuperBOL LSP to your coc configuration:

{
  "colors.enable": true,
  "languageserver": {
    "cobol": {
      "command": "opam",
      "args": [ "exec",
        "--switch",
        "superbol-studio",
        "--",
        "superbol-free",
        "lsp",
        "--force-syntax-diagnostics",
      ],
      "filetypes": ["cobol"]
    }
  },
}

If you wish to use semantic highlighting with coc, you must add to the coc configuration:

"semanticTokens.enable": true

and to your vim configuration:

au FileType cobol setlocal syntax=OFF

vim-lsp

To work with vim-lsp you should add to your configuration:

if executable('opam')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'superbol',
        \ 'cmd': {server_info->['opam', 'exec', '--switch', 'superbol-studio', '--', 'superbol-free', 'lsp', '--force-syntax-diagnostics']},
        \ 'allowlist': ['cobol'],
        \ })
endif

If you want semantic highlighting to work with vim-lsp you can add to your configuration:

let g:lsp_semantic_enabled = 1
au FileType cobol setlocal syntax=OFF

Install for Neovim

You must have neovim/nvim-lspconfig installed.

Add these lines to your neovim configuration:

require("lspconfig.configs").cobol = {
  default_config = {
    cmd = {
      "opam",
      "exec",
      "--switch",
      "superbol-studio",
      "--",
      "superbol-free",
      "lsp",
      "--force-syntax-diagnostics",
    },
    filetypes = { "cobol" },
    root_dir = function(startpath)
      return require("lspconfig").util.find_git_ancestor(startpath)
        or require("lspconfig").util.path.dirname(startpath)
    end,
    settings = {},
  },
}

require("lspconfig").cobol.setup({
  on_attach = my_attach_function, -- should be the same as your other lsp
  capabilities = my_capabilities, -- should be the same as other lsp
})