Giter Club home page Giter Club logo

dls's Introduction

D Language Server

GitHub

DUB Travis AppVeyor
DUB Travis AppVeyor

LSP compliance: 3.13

This is still a work in progress; there might still be bugs and crashes

DLS implements the server side of the Language Server Protocol (LSP) for the D programming language. It doesn't do much itself (yet), and rather uses already available components, and provides an interface to work with the LSP. Current features include:

  • Code completion
  • Going to symbol definition
  • Finding references
  • Symbol renaming
  • Error checking
  • Code formatting (document, range and on-type)
  • Symbol listing (current document and workspace-wide)
  • Symbol highlighting
  • Documentation on hover
  • Random, frustrating crashes

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).

Some common editors

DLS should work with other editors, although your mileage may vary since it's moslty tested on the ones above. If it's not working with your editor of choice, submit an issue!

Command line options

Some command line options exist to control the behavior of DLS:

  • --stdio: use standard input and output streams for communication
  • --socket=PORT or --tcp=PORT: use a socket connecting on the specified port for communication

Installing

You can run dub fetch dls and then dub run dls:bootstrap to install dls. The second command will output a path that will point to the DLS executable. DLS will automatically update itself whenever a new version is out.

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.initializationOptions object sent with the initialize request:

interface InitializationOptions: {
    autoUpdate?: boolean;
    catchErrors?: boolean;
    logFile?: string;
    capabilities?: {
        hover?: boolean;
        completion?: boolean;
        definition?: boolean;
        typeDefinition?: boolean;
        references?: boolean;
        documentHighlight?: boolean;
        documentSymbol?: boolean;
        workspaceSymbol?: boolean;
        codeAction?: boolean;
        documentFormatting?: boolean;
        documentRangeFormatting?: boolean;
        documentOnTypeFormatting?: boolean;
        rename?: boolean;
    }
}

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 can be regenerated on demand. Watching *.ini allows DLS to monitor D-Scanner config files, even if the name is changed in the config and isn't dscanner.ini.

Custom messages

Since 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/didStart Notification TranslationParams Sent when the upgrade process starts
$/dls/upgradeDls/didStop Notification null Sent when the upgrade process stops
$/dls/upgradeDls/didChangeTotalSize Notification DlsUpgradeSizeParams Sent during the download, with the total size of the upgrade download
$/dls/upgradeDls/didChangeCurrentSize Notification DlsUpgradeSizeParams Sent during the download, with the current size of the upgrade download
$/dls/upgradeDls/didExtract Notification TranslationParams Sent when the download is finished and the contents are written on the disk
$/dls/upgradeSelections/didStart Notification TranslationParams Sent when DLS starts upgrading dub.selections.json
$/dls/upgradeSelections/didStop 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 message objects with the locale identifier as key and the translated string as value.

dls's People

Contributors

laurenttreguier avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.