dls 0.6.3

D Language Server


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

This package provides sub packages which can be used individually:

dls:bootstrap - DLS bootstrap utility

D Language Server

DUB Package Build Status Build status

LSP compliance: 3.7.0

This is a work in progress. There ~~might~~ will be bugs and crashes...

DLS implements the server side of the Language Server Protocol (LSP) for the D programming language. It does not contain any language feature itself (yet), but uses already available components, and provides an interface to work with the LSP. Current features include:

  • Code completion
  • Go to definition
  • Error checking
  • Formatting
  • Symbol searching
  • Symbol highlighting
  • Documentation on hover
  • Random crashes

Libraries used (the stuff doing the actual hard work):

Installing

You can run dub fetch dls and then dub run dls:bootstrap to install dls. The second command will output a path to a symbolic link that will always point to the latest DLS executable. DLS will propose updates as they come, and update the symbolic link upon upgrading.

Client side configuration

All these keys should be formatted as d.dls.[section].[key] (e.g. d.dls.format.endOfLine).

Section: symbolTypeDefault value
importPathsstring[][]
Section: analysisTypeDefault value
configFilestring"dscanner.ini"
Section: formatTypeDefault value
endOfLine"lf" or "cr" or "crlf""lf"
maxLineLengthnumber120
dfmtAlignSwitchStatementsbooleantrue
dfmtBraceStyle"allman" or "otbs" or "stroustrup""allman"
dfmtOutdentAttributesbooleantrue
dfmtSoftMaxLineLengthnumber80
dfmtSpaceAfterCastbooleantrue
dfmtSpaceAfterKeywordsbooleantrue
dfmtSpaceBeforeFunctionParametersbooleanfalse
dfmtSplitOperatorAtLineEndbooleanfalse
dfmtSelectiveImportSpacebooleantrue
dfmtCompactLabeledStatementsbooleantrue
dfmtTemplateConstraintStyle"conditionalNewlineIndent" or "conditionalNewline" or "alwaysNewline" or "alwaysNewlineIndent""conditionalNewlineIndent"
dfmtSingleTemplateConstraintIndentbooleanfalse

Server initialization options

DLS supports a few custom initialization options in the InitializeParams object sent with the initialize request:

initializationOptions: {
    capabilities: {
        completion: true;
        hover: true;
        documentFormatting: true;
        definition: true;
        documentHighlight: true;
        documentSymbol: true;
        workspaceSymbol: true;
    }
}

The bootstrap subpackage and the update system

In order to simplify the process of updating DLS, an update system is implemented. However, the extension will need to locate a first version of DLS; this is where dls:bootstrap comes in. The steps are:

  • dub fetch dls will fetch the latest version of DLS
  • dub run --quiet dls:bootstrap will output the path to a symlink pointing to the latest DLS executable

Nothing specific is required on the client's part regarding updates: the server will send notifications to the user when an update is available, and download/build the new version (in parallel to responding to requests). Binary downloads are available and should be picked up automatically for Windows, macOS and Linux in both x86 and x86_64 flavors.

Caveats

The server may delegate a few operations to the client-side extension depending on the language client's capabilities. The client should watch these files for the server to work properly:

  • dub.selections.json
  • dub.json
  • dub.sdl
  • *.ini

If the client supports dynamic registration of the workspace/didChangeWatchedFiles method, then the server will automatically register file watching. If the client doesn't support dynamic registration however, the client-side extension will need to manually do it. The server needs to know at least when dub.selections.json files change to properly provide completion support. If dub.json and dub.sdl are also watched, dub.selections.json will automatically be regenerated and then it will be used for completion support. Watching *.ini allows DLS to monitor D-Scanner config files, even if the name is changed in the config and isn't precisly dscanner.ini.

Custom messages

The LSP defines messages with methods starting in $/ to be implementation dependant. DLS uses $/dls as a prefix for some custom messages.

MessageTypeParameterDescription
$/dls.upgradeDls.startNotificationnullSent when the upgrade process starts
$/dls.upgradeDls.stopNotificationnullSent when the upgrade process stops
$/dls.upgradeDls.totalSizeNotificationnumberSent during the download, with the total size of the upgrade download
$/dls.upgradeDls.chunkSizeNotificationnumberSent during the download, with the size of a chunk that was just downloaded
$/dls.upgradeDls.extractNotificationnullSent when the download is finished and the contents are written on the disk
$/dls.upgradeSelections.startNotificationnumberSent when DLS starts upgrading dub.selections.json
$/dls.upgradeSelections.stopNotificationnullSent when DLS has finished upgrading dub.selections.json

Example usage

I made a VSCode extension and an Atom package using DLS:

  • https://github.com/LaurentTreguier/vscode-dls
  • https://github.com/LaurentTreguier/ide-dlang
Authors:
  • Laurent Tréguier
Sub packages:
dls:bootstrap
Dependencies:
dcd, arsd-official:color_base, dfmt, arsd-official:email, dub, dls:bootstrap, dscanner
Versions:
0.6.3 2018-Jun-19
0.6.2 2018-Jun-17
0.6.1 2018-Jun-16
0.6.0 2018-Jun-11
0.5.10 2018-Jun-10
Show all 28 versions
Download Stats:
  • 7 downloads today

  • 28 downloads this week

  • 117 downloads this month

  • 253 downloads total

Score:
1.8
Short URL:
dls.dub.pm