dls 0.8.2
D Language Server
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
This package provides sub packages which can be used individually:
dls:bootstrap - DLS bootstrap utility
dls:gen - DLS translations generator
dls:i18n - DLS translation utilities
dls:protocol - LSP interfaces implementations
D Language Server
DUB | Travis | AppVeyor |
---|---|---|
LSP compliance: 3.10.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
- Symbol renaming at module level (not accross entire projects)
- Random, frustrating crashes
Dub packages used (the stuff doing the actual hard work):
Usage
Some editors may need DLS to be installed manually (don't worry it's easy).
- Visual Studio Code: install the extension
- Atom: install the package
- Sublime Text (using tomv654's LSP client):
"clients": { "dls": { "command": [ "[path to dls executable]" ], "enabled": true, "languageId": "d", "scopes": [ "source.d" ], "syntaxes": [ "Packages/D/D.sublime-syntax" ] } }
DLS may or may not work with other editors. Given the editor-neutral nature of the LSP, it should work, but given the nature of DLS, it should have some weird quirks. If it's not working with your editor of choice, submit an issue!
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 offer updates as they come, and update the symbolic link accordingly.
Client side configuration
All these keys should be formatted as d.dls.[section].[key]
(e.g. d.dls.format.endOfLine
).
Section: symbol | Type | Default value |
---|---|---|
importPaths | string[] | [] |
Section: analysis | Type | Default value |
---|---|---|
configFile | string | "dscanner.ini" |
Section: format | Type | Default value |
---|---|---|
endOfLine | "lf" or "cr" or "crlf" | "lf" |
maxLineLength | number | 120 |
dfmtAlignSwitchStatements | boolean | true |
dfmtBraceStyle | "allman" or "otbs" or "stroustrup" | "allman" |
dfmtOutdentAttributes | boolean | true |
dfmtSoftMaxLineLength | number | 80 |
dfmtSpaceAfterCast | boolean | true |
dfmtSpaceAfterKeywords | boolean | true |
dfmtSpaceBeforeFunctionParameters | boolean | false |
dfmtSplitOperatorAtLineEnd | boolean | false |
dfmtSelectiveImportSpace | boolean | true |
dfmtCompactLabeledStatements | boolean | true |
dfmtTemplateConstraintStyle | "conditionalNewlineIndent" or "conditionalNewline" or "alwaysNewline" or "alwaysNewlineIndent" | "conditionalNewlineIndent" |
dfmtSingleTemplateConstraintIndent | boolean | false |
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 DLSdub 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 custom messages.
Message | Type | Parameters | Description |
---|---|---|---|
$/dls.upgradeDls.start | Notification | TranslationParams | Sent when the upgrade process starts |
$/dls.upgradeDls.stop | Notification | null | Sent when the upgrade process stops |
$/dls.upgradeDls.totalSize | Notification | DlsUpgradeSizeParams | Sent during the download, with the total size of the upgrade download |
$/dls.upgradeDls.currentSize | Notification | DlsUpgradeSizeParams | Sent during the download, with the current size of the upgrade download |
$/dls.upgradeDls.extract | Notification | TranslationParams | Sent when the download is finished and the contents are written on the disk |
$/dls.upgradeSelections.start | Notification | TranslationParams | Sent when DLS starts upgrading dub.selections.json |
$/dls.upgradeSelections.stop | Notification | null | Sent when DLS has finished upgrading dub.selections.json |
interface TranslationParams {
tr: string;
}
interface DlsUpgradeSizeParams extends TranslationParams {
size: number;
}
Contributing
Translations
The file i18n/data/translations.json
contains localization strings.
Adding new strings is straightforward, simply add new entries in the title
objects with the locale as key and the translation as value.
- Registered by Laurent Tréguier
- 0.8.2 released 5 years ago
- d-language-server/dls
- GPL-3.0 or later
- Copyright © 2017, Laurent Tréguier
- Authors:
- Sub packages:
- dls:bootstrap, dls:gen, dls:i18n, dls:protocol
- Dependencies:
- dls:bootstrap, dub, dscanner, dcd, dls:protocol, dls:i18n, dfmt
- Versions:
-
0.26.2 2020-Mar-20 0.26.1 2020-Jan-25 0.26.0 2019-Dec-03 0.25.19 2019-Oct-29 0.25.18 2019-Oct-28 - Download Stats:
-
-
0 downloads today
-
1 downloads this week
-
3 downloads this month
-
13852 downloads total
-
- Score:
- 2.2
- Short URL:
- dls.dub.pm