Coder Social home page Coder Social logo

Add support for Arduino about vscode-dash HOT 6 CLOSED

deerawan avatar deerawan commented on September 1, 2024
Add support for Arduino

from vscode-dash.

Comments (6)

akdir avatar akdir commented on September 1, 2024

I would like to add Arduino Support for this extension @deerawan. So I already looked at it and it seems like VSCode sees Arduino .ino file as a .cpp file, because the output of the vscode.window.activeEditor.document.languageId is cpp for ino files. That means you can add Arduino support by adding arduino as a key to the value cpp in the package.json file. But adding a new key/value pair for arduino itself will not work, because VSCode sees Arduino files as cpp files.

So should I just add it to the cpp value? I would like to hear from you @deerawan.

from vscode-dash.

akdir avatar akdir commented on September 1, 2024

Now I can also fix this by adding this little if statement in the function getDocSets() in extension.ts to force it to get the arduino languageId correctly.

So then the function will be:

/**
 * Get docset configuration
 *
 * @param {string} languageId e.g javascript, ruby
 * @return {string}
 */
function getDocsets(): string[] {
  const editor = getEditor() as TextEditor;
  const fileName = path.basename(editor.document.fileName);
  const languageId = editor.document.languageId;

  const fileNameDocsets = getFileNameDocsets(fileName);
  var languageIdDocsets = getLanguageIdDocsets(languageId);

  // To get arduino fileName correctly, because VSCode editor.document.languageId is cpp for arduino(ino) files!
  if (fileName.split('.').pop() == 'ino') {
    languageIdDocsets = getLanguageIdDocsets('arduino');
  }

  // prioritize docset matching by file name then language id
  return [...fileNameDocsets, ...languageIdDocsets];
}

What do you think is better @deerawan. Maybe there is another way that I do not know of, but that is the only way I could add support for Arduino.

from vscode-dash.

deerawan avatar deerawan commented on September 1, 2024

Hi @akdir, just noticed your message. Thank you.

Let me do some investigation.

from vscode-dash.

deerawan avatar deerawan commented on September 1, 2024

@akdir have you installed the extension https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino? This is in order to detect the language ID correctly.

from vscode-dash.

akdir avatar akdir commented on September 1, 2024

@akdir have you installed the extension https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino? This is in order to detect the language ID correctly.

@deerawan , Yes that is the first thing I did. That did not change the vscode.window.activeEditor.document.languageId output, it is still cpp for ino files. So I thought maybe VSCode sees ino files just as CPP files, because afterall the "programming language" Arduino is based on C/C++ but has some special functions to interact with Analog and Digital I/O.

from vscode-dash.

deerawan avatar deerawan commented on September 1, 2024

interesting, maybe we can do the alternative way by detecting the filename https://github.com/deerawan/vscode-dash#file-name-to-docset-matching

from vscode-dash.

Related Issues (20)

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.