Skip to content

Commit

Permalink
detect the most suitable syntax from languageId
Browse files Browse the repository at this point in the history
  • Loading branch information
shinnn committed Nov 15, 2016
1 parent d707fdd commit a0799de
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const path = require('path');

const langServer = require('vscode-languageserver');
const Files = langServer.Files;
const stylelintVSCode = require('stylelint-vscode');
Expand All @@ -13,10 +11,7 @@ let configOverrides;
const connection = langServer.createConnection(process.stdin, process.stdout);
const documents = new langServer.TextDocuments();

const syntaxConfig = {
'.scss': 'scss',
'.less': 'less'
};
const supportedCustomSyntaxes = new Set(['less', 'scss']);

function validate(document) {
return stylelintVSCode({
Expand All @@ -25,7 +20,7 @@ function validate(document) {
config,
configOverrides,
configBasedir,
syntax: syntaxConfig[path.extname(String(document.uri)).toLowerCase()]
syntax: supportedCustomSyntaxes.has(document.languageId) ? document.languageId : null
}).then(diagnostics => {
connection.sendDiagnostics({uri: document.uri, diagnostics});
}).catch(err => {
Expand Down

0 comments on commit a0799de

Please sign in to comment.