Skip to content

Commit

Permalink
Merge pull request #46 from joeveiga/feat/init-options
Browse files Browse the repository at this point in the history
feat: allow global config via init options
  • Loading branch information
aca authored Jul 19, 2022
2 parents 14db837 + f1b1bc9 commit 2f016b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ lspconfig.emmet_ls.setup({
-- on_attach = on_attach,
capabilities = capabilities,
filetypes = { 'html', 'typescriptreact', 'javascriptreact', 'css', 'sass', 'scss', 'less' },
init_options = {
html = {
options = {
-- For possible options, see: https://github.com/emmetio/emmet/blob/master/src/config.ts#L79-L267
["bem.enabled"] = true,
},
},
}
})
```

Expand Down
18 changes: 5 additions & 13 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
extract,
GlobalConfig,
parseMarkup,
parseStylesheet,
resolveConfig,
Expand Down Expand Up @@ -30,6 +31,7 @@ const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);

let hasConfigurationCapability: boolean = false;
let hasWorkspaceFolderCapability: boolean = false;
let globalConfig: GlobalConfig = {};

connection.onInitialize((params: InitializeParams) => {
const capabilities = params.capabilities;
Expand All @@ -43,6 +45,8 @@ connection.onInitialize((params: InitializeParams) => {
capabilities.workspace && !!capabilities.workspace.workspaceFolders
);

globalConfig = params.initializationOptions || {};

const triggerCharacters = [
">",
")",
Expand Down Expand Up @@ -130,18 +134,6 @@ connection.onInitialized(() => {
}
});

// The example settings
interface ExampleSettings {
maxNumberOfProblems: number;
}

// Cache the settings of all open documents
const documentSettings: Map<string, Thenable<ExampleSettings>> = new Map();

documents.onDidClose((e) => {
documentSettings.delete(e.document.uri);
});

// For list of language identifiers, see:
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentItem
// For list of supported syntax options, see:
Expand Down Expand Up @@ -196,7 +188,7 @@ connection.onCompletion(
"output.field": (index, placeholder) =>
`\$\{${index}${placeholder ? ":" + placeholder : ""}\}`,
},
});
}, globalConfig);

let textResult = "";
if (!isStylesheet) {
Expand Down

0 comments on commit 2f016b2

Please sign in to comment.