How to include specific hidden file/folder in search result when using telescope.nvim? - neovim

I'm using neovim and Telescope as a finder (find_files, live_grep, file_browser), by default Telescope is ignoring hidden files and files included in .gitignore - how can I add exception (e.g. .gitlab-ci file/folder) to this list? so Telescope will still ignore hidden files except .gitlab-ci file/folder?

Use default filter ignore pattern for that like that
telescope.setup {
....
defaults = {
....
file_ignore_patterns = {
"node_modules", "build", "dist", "yarn.lock"
},
}
}
I know you can find this in someone's vimrc files or telescope docs. But may help some newbies.

Telescope uses ripgrep to search through files. By default, ripgrep ignores several groups of files, including hidden files (dotfiles) and files ignored by git. Adding --no-ignore-vcs and --hidden flags will make it to search through those files.
Arguments for ripgrep can be configured via defaults.vimgrep_arguments.
In your case, to search through hidden files, which are not in .gitignore --hidden flag should be added:
require('telescope').setup{
defaults = {
vimgrep_arguments = {
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case',
'--hidden',
},
}
You can always test the command from the terminal before changing the Telescope configuration:
rg ... --hidden <search string>
As --hidden will enable search through all hidden files, you might want to look into .ignore or .rgignore files. They tell ripgrep which files to ignore during search. See ripgrep's documentation for more info.

After several weeks of intense reading and testing, I have found the for me easiest solution here.
In order to find HIDDEN FILES, I have added the following lines to
.config/nvim/init.vim
nnoremap fff <cmd>Telescope find_files <cr>
nnoremap ffh <cmd>Telescope find_files hidden=true<cr>
When yo launch Neovim UI, pressing fff pops up the Telescope find_file screen, and when you press ffh, you can search for HIDDEN files.
To search for hidden files in LIVE_GREP, the work was a bit more difficult.
From my perspective, the most elegant solution is to first create the following file : .config/nvim/lua/find_hidden.lua
Inside goes :
local telescope = require("telescope")
local telescopeConfig = require("telescope.config")
-- Clone the default Telescope configuration
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
-- I want to search in hidden/dot files.
table.insert(vimgrep_arguments, "--hidden")
-- I don't want to search in the `.git` directory.
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")
telescope.setup({
defaults = {
-- `hidden = true` is not supported in text grep commands.
hidden = true,
vimgrep_arguments = vimgrep_arguments,
},
pickers = {
find_files= {
hidden = true,
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
},
},
})
----- This activates the search for hidden files in live_grep
require("telescope").setup {
pickers = {
live_grep = {
additional_args = function(_ts)
return {"--hidden"}
end
},
},
}
The add the following the following lines to your init.vim :
:lua require('find_hidden')
nnoremap gre <cmd>Telescope live_grep <cr>
To sum it up: with the find_hidden.lua file and the following lines in your init.vim, you can easily search for hidden and non-hidden files both in telescope_find_files and telescope_live_grep :
:lua require('find_hidden')
nnoremap fff <cmd>Telescope find_files <cr>
nnoremap ffh <cmd>Telescope find_files hidden=true<cr>
nnoremap gre <cmd>Telescope live_grep <cr>

Related

How to config the autoformat no Lunar Vim

I'm newer on vim and your forks. To have a smoother transition I'm using Lunar Vim, but I need to change some option about the formatter, for example:
How I need to format:
<img src={ item.image } alt ={ item.descripton } />
But when I save, the Vim format like:
<img src={item.image} alt ={item.descripton} />
(Without spaces)
I need to change this, or remove the auto formatter.
There are two ways to do this, you can do it with the easy way (answer of Jorge Dorino).
File: /home/user/.config/lvim/config.lua
lvim.format_on_save = true -- Disable this line
Or you can keep this line and activate the prettier formatter https://prettier.io/docs/en/options.html , and configure your own rules to html files formatting.
(You need to install prettier or prettierd before do this)
File: /home/user/.config/lvim/config.lua
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
{ exe = "prettierd", filetypes = { "html" } }
}

How to get the name of selected files in source control via VSCode extension API?

I can manage to get one file name of source control with following code. The file name is from the line 'await vscode.commands.executeCommand('copyFilePath');' I can get the file name by reading the clipboard text. But when I select multiple files, still the first file name is available. Is it possible to get all files' name?
let copySelectedFileName = vscode.commands.registerCommand('folder-operations.copySelectedFileName', async (folder) => {
let newUri = folder; // folder will be undefined when triggered by keybinding
console.log('folder'+folder);
if (!folder) { // so triggered by a keybinding
await vscode.commands.executeCommand('copyFilePath');
}
console.log(newUri);
});
I try another way: add one command to SCM as below shown.
I use parameter in command to retrieve the selected files' name. But the size of the array is 1 even if I choose more than 2 files.
let copySelectedFileNameSCM = vscode.commands.registerCommand('testSource.copySelectedFileNameSCM', async (...file) => {
console.log('file:'+file);
});
Add your command to this context menu in your package.json:
"contributes": {
"menus": {
"scm/resourceState/context": [
{
"command": "testSource.copySelectedFileNameSCM"
}
]
}
}
It looks like you were adding it to the wrong menu. That may be the only menu that will return selected files.
Then in your command:
let copySelectedFileNameSCM = vscode.commands.registerCommand('testSource.copySelectedFileNameSCM', async (...file) => {
console.log('file:'+file);
});
file will be an array of all selected items in the scm view when you trigger a context menu on one or more selected files.

How to stop new lines when formatting code

EDIT: It is Beautify that is adding the new lines. Not sure which rule though.
Is there a way to stop parameter lists and import lists from adding new lines per each list item when formatting code with?
E.g stop this:
function view(state$) {
return state$.map(({weight,height,bmi}) =>
div([
renderWeightSlider(weight),
renderHeightSlider(height),
h2('BMI is ' + bmi)
])
);
}
from becoming this:
function view(state$) {
return state$.map(({
weight,
height,
bmi
}) =>
div([
renderWeightSlider(weight),
renderHeightSlider(height),
h2('BMI is ' + bmi)
])
);
}
When right-clicking and selecting "format document"?
It also does it with imports like so:
import {
makeDOMDriver,
h1,
a
} from '#cycle/dom';
However it is unwanted.
create or edit .jsbeautifyrc file in your root from you vscode project and put in to the file this json property
{
"brace_style": "collapse,preserve-inline"
}
this will also prevent to format all JavaScript object
Include "brace_style": "collapse,preserve-inline" as Yitzchak said inside the .json settings file located here:
C:\Users\***\AppData\Roaming\Code\User\settings.json
2021 Update for Eze_82's answer:
Instead of just "brace_style": "collapse,preserve-inline", you now need to include the following in the settings.json file of VSCode:
"beautify.config": {
"brace_style": "collapse,preserve-inline"
}
The location of the settings.json is still the same.

Adding keyboard shortcuts for move cell up and move cell down

I am trying to add the Cntl+K and Cntl+J shortcuts to move cells up and down quickly. I viewed the issue on Github here for adding the shortcuts and found what looked to be a workable answer:
"For those (like me) who liked this shortcut, add this to your ~/.ipython/profile_default/static/custom/custom.js:
$([IPython.events]).on("app_initialized.NotebookApp", function () {
IPython.keyboard_manager.command_shortcuts.add_shortcut('ctrl-k', function (event) {
IPython.notebook.move_cell_up();
return false;
});
IPython.keyboard_manager.command_shortcuts.add_shortcut('ctrl-j', function (event) {
IPython.notebook.move_cell_down();
return false;
});
});
"
But my users/{my name}/.ipython/profile_default directory did not have a static folder. I tried adding the missing folders and custom.js file, and reopened Anaconda prompt, but this did not add the missing shortcuts.
Another answer had the same issue:
"Use the following:
$ cat ~/.jupyter/custom/custom.js
define(["base/js/namespace"], function(Jupyter){
console.info('Binding Ctrl-J/K to move cell up/down');
Jupyter.keyboard_manager.command_shortcuts.add_shortcut('Ctrl-k','jupyter-notebook:move-cell-up');
Jupyter.keyboard_manager.command_shortcuts.add_shortcut('Ctrl-j','jupyter-notebook:move-cell-down');
});
"
This answer also did not work (adding the missing folder and custom.js file did not work).
As proposed in the official doc (got with the "Help>Notebook" menu action),
you could try first in a live notebook. The browser javascript console helps too.
I tried:
%%javascript
IPython.keyboard_manager.command_shortcuts.add_shortcut('Ctrl-k','jupyter-notebook:move-cell-up');
// replacing IPython with Jupyter should work as well:
Jupyterkeyboard_manager.command_shortcuts.add_shortcut('Ctrl-j','jupyter-notebook:move-cell-down');
It works but, just as when clicking on the corresponding toolbar button, the console warns about deprecation
in favor of IPython.notebook.move_selection_up() .
The string "jupyter-notebook:move-cell-up" refers to the same action.
So I suppose a reasonnable thing to do is to redefine it from scratch:
IPython.keyboard_manager.command_shortcuts.add_shortcut('Ctrl-k', {
help : 'move up selected cells',
help_index : 'jupyter-notebook:move-selection-up',
handler : function (event) {
IPython.notebook.move_selection_up();
return false;
}}
);
IPython.keyboard_manager.command_shortcuts.add_shortcut('Ctrl-j', {
help : 'move down selected cells',
help_index : 'jupyter-notebook:move-selection-down',
handler : function (event) {
IPython.notebook.move_selection_down();
return false;
}}
);
After executing the notbook cell (or the code in your browser console), it should
be active and you can experiment with it.
Once happy, check the path of your jupyter profile with !jupyter --config, and from there
you'd know where to copy your code : <profile>/static/custom/custom.js
so that it would be active in next jupyter sessions.

CKEditor, Plugin Conflict

I recently started to use CKEditor, i have come across to somewhat a weird problem, i have downloaded two plugins ,the "texttransform" and "autogrow",my config file looks like this ,,,
****CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
CKEDITOR.config.extraPlugins = 'texttransform'
config.extraPlugins = 'autogrow';
};****
The problem is, at one time only one plugin is active and functionality of other plugin disappears, for example,when i added autogrow, the control buttons of texttransform disappears,and they only work when i remove the line "config.extraPlugins = 'autogrow';" from my config file, any thoughts?
You are setting the configuration incorrectly. You must set config.extraPlugins only once, with two plugin names:
CKEDITOR.editorConfig = function( config ) {
config.extraPlugins = 'autogrow,texttransform';
};
See also the documentation.