Skip to content

Latest commit

 

History

History
84 lines (67 loc) · 2.08 KB

editor-vim.md

File metadata and controls

84 lines (67 loc) · 2.08 KB

serve-d with Vim / NeoVim

Using ycmd

Download or build serve-d and edit your .vimrc.

let g:ycm_language_server = [
            \ {
            \     'name': 'd',
            \     'cmdline': ['path/to/your/serve-d/binary'],
            \     'filetypes': ['d'],
            \ }]

Familiarize yourself with how ycmd handles .ycm_extra_conf.py files. For serve-d, it is important that you give ycmd the LSP arguments in the right format. The basic setup for establishing autocomplete with the D standard library needs the path (or, if multiple paths, an array of them) to your D standard library on your system.

def Settings(**kwargs):
    lang = kwargs['language']
    if lang == 'd':
        return { 'ls': {
                   'd': { 'stdlibPath': '/path/to/your/stdlib' }
                   # In case you need multiple paths, do
                   # 'd' : { 'stdlibPath': ['/path/to', '/your/stdlibs']}
                   # For other config options, see README.md
                 }
               }
    else:
        return {}

Put this in a file called .ycm_extra_conf.py and save it in your project root or move it further up the folder hierarchy, if you know what you are doing.

Using coc's

Using CocInstall

:CocInstall coc-dlang

Manually through coc-settings.json

First download or build serve-d

A coc-settings.json file looking like this works well (you can open it with :CocConfig)

{
	"languageserver": {
		"d": {
			"command": "PATH_TO_SERVE_D_EXECUTABLE/serve-d",
			"filetypes": ["d"],
			"trace.server": "on",
			"rootPatterns": ["dub.json", "dub.sdl"],
			"initializationOptions": {
			},
			"settings": {
			}
		}
	},
	"suggest.autoTrigger": "none",
	"suggest.noselect": false
}

Using nvim-lspconfig

Neovim has a builtin LSP client and official LSP configs for it, here.

After installing nvim-lspconfig using your preferred plugin manager, you must load serve-d, like the following:

require'lspconfig'.serve_d.setup{}