I use CTRL+Click (or F12) to search and open the definitions in vscode. The problem is that my files are copied to another directory called sketch as I compile my code, so when I wanna open the definition of a function, VS shows both files (the real and the copied ones in the sketch folder), and sometimes I edit the copied file by mistake!
How can I exclude some folders from the "Go To definition"?
I had the same problem in a Javascript project.
None of the following solved it for me: files.exclude, files.watcherExclude, or search.exclude.
The solution was to add jsconfig.json to my project folder:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"Backup",
"Sketch"
]
}
This example specifies two folders to exclude: "Backup", and "Sketch".
If you are using TypeScript, use a tsconfig.json file instead.
Also see https://code.visualstudio.com/docs/languages/jsconfig
Add files to C:\Users\user\AppData\Roaming\Code\User\settings.json:
"files.exclude": {
"**/sketch": true
},
Or files to exclude when searching (in files):
"files.watcherExclude": {
"**/*.x": true,
},
Related
I noticed, if I define a c_cpp_properties.json for the "C/C++" plugin in my user config folder "~/.vscode" instead of the project config folder, the file is not parsed. My aim is to define some global include directories, which are used in all projects. I haven't found a clear answer whether and how this is possible (or not).
{
"configurations": [
{
"includePath": [
"/foo/*"
]
}
]
}
I work with Javascript/React. When I try to type a name of module, exported from another file, VSCode doesn't advise me the module, but if I open the file with imported module, VSCode begins to autoimport it well. Sometimes it's require to resave file. I have the same problem with automatically changing imports when moving file. It have the same solution. Does anybody know if there is any buffer/indexation for files in VSCode or something alike?
I found the solution. You should create jsconfig.json in your project folder and add the next code there (it was enough for me):
{
"compilerOptions": {
"module": "commonjs",
"target": "es6"
},
"exclude": ["node_modules"]
}
also you can config it at file hui.pdf. But it works if you use ikar - version only with anaconda.(It's works in north asia only in Siberia)
you shold to find this file and add a string :
"exclude": ["node_modules"]
"compilerOptions": [new_reo21]
When writing a javascript app, it's possible to create an .env file in the root directory containing just e.g:
NODE_PATH=src/
Which sets up allowing for absolute paths e.g: in import statements in code.
e.g: I can be working on the file /src/actions/index.js and enter:
import { SAVE_COMMENT } from "actions/types";
..and the import works, but there is no auto-complete and I wonder: Is it possible to auto-complete after I type just:
import { SAVE_COMMENT } from "actions/
?
Relative-path lookup continues to work great. In fact, the relative path lookup is one of my favorite features of vs-code and one of the reasons I use it, so it would be very nice for it to work when absolute paths are configured, too.
VS Code does not support using NODE_PATH for intellisense. To achieve what you want, create a jsconfig.json file at the root of your project with the contents:
{
"compilerOptions": {
"target": "ES6",
"baseUrl": "./src"
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
The important setting is baseUrl. It tells VS Code to resolve non-relative paths relative to the ./src folder
After configuring jsconfig and baseUrl, you can also set "javascript.preferences.importModuleSpecifier": "non-relative" in VS Code to specify that VS Code should always try to use paths to use the baseUrl
Here is a nice guide for Vue.js and Nuxt.js projects configuration in VS Code
this is the solution that worked for me
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"core/*": ["./src/*"],
}
}
}
I am using webpack and absolute paths
I have some .txt files in a subfolder of my project which contain SQL code. I want SQL syntax highlighting so I added this to my workspace folder settings:
{
"files.associations": {
"**/somefolder/*.txt": "sql"
}
}
This works when there are the two stars in front of the folder name. But somefolder actually is a folder direct under my project's root.
Why can I not write the glob like somefolder/**/*.txt?
Seems like this new version of VSCode requires you to use the ** at the start regardless:
{
"files.associations": {
"**/somefolder/**/*.txt": "sql"
}
}
That should work
For a jekyll site the following workspace setting works for me
{
"files.associations": {
"*.html": "jekyll",
"**/_site/**/*.html": "html",
}
}
I am working with es6 syntax in Visual Studio Code and when I import ordinary file, then I can click F12 (Go to definition) and it works just fine. The problem is that with components (import from .jsx files) it does not work at all (nothing happens when you click go to definition). Has anyone an idea how it can be fixed?
P.S. I have jsconfig.json like that to allow proper go to definition for ordinary .js files:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules"
]
}
Although you can track down the solution from github issues mentioned in one of the comments, I wanted to make it easier for SO users. Quote from the Github issues page:
easy workaround is to add the compilerOption "jsx": "preserve" (or
"jsx": "react" or "jsx": "react-native")
jsconfig.json:
{
"compilerOptions": {
"jsx": "react"
}
}