I'm using neovim for coding C++. I have some trouble when coding with it.
I often use file to read and write data. When I run C++ file by command g++ -o data data.cpp && ./data, output file don't reload in neovim.
I try use
set autoread
au CursorHold * checktime
but it doesn't work.
I don't want to type :e to reload everytime I run code
Additionally, I want to know how to set auto reload nerbtreee when I create new file or folder on Explorer.
Environment:
nvim: 0.4.3
Ubuntu 18.04 LTS
I solved it.
Thanks for spacetime-continuum on Reddit
This is how I configure for this problem:
" trigger `autoread` when files changes on disk
set autoread
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" notification after file change
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
Here is how I auto-read buffers using lua Config
vim.o.autoread = true
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, {
command = "if mode() != 'c' | checktime | endif",
pattern = { "*" },
})
Related
I'm totally new to neovim. I already snap-installed neovim (Ubuntu) and I want now to install nvim-tree.
The documentation confuses me.
Here is my file .config/nvim/init.vim
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
Plug 'nvim-tree/nvim-tree.lua'
call plug#end()
Now calling :PlugInstall in neovim seems to install something.
But in the "Setup" part of the doc, it is said to add this in init.lua:
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require("nvim-tree").setup()
Since init.vim and init.lua are exclusive, I do not know what to do.
If I remove init.vim and create the file init.lua, I get this error:
E5113: Error while calling lua chunk: /home/laurent/.config/nvim/init.lua:4: module 'nvim-tree' not foun
d:
no field package.preload['nvim-tree']
no file './nvim-tree.lua'
no file '/build/nvim/parts/nvim/build/.deps/usr/share/luajit-2.1.0-beta3/nvim-tree.lua'
no file '/usr/local/share/lua/5.1/nvim-tree.lua'
no file '/usr/local/share/lua/5.1/nvim-tree/init.lua'
no file '/build/nvim/parts/nvim/build/.deps/usr/share/lua/5.1/nvim-tree.lua'
no file '/build/nvim/parts/nvim/build/.deps/usr/share/lua/5.1/nvim-tree/init.lua'
no file './nvim-tree.so'
no file '/usr/local/lib/lua/5.1/nvim-tree.so'
no file '/build/nvim/parts/nvim/build/.deps/usr/lib/lua/5.1/nvim-tree.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
/home/laurent/.config/nvim/init.lua:4: in main chunk
QUESTIONS:
Do I have to stick with init.vim or init.lua (or is it a choice with no consequences ?)
How do I install/use the plugin nvim-tree ?
Answer to myself. It turns out that this works:
In ~/.config/nvim/init.vim:
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
Plug 'nvim-tree/nvim-tree.lua'
call plug#end()
lua << EOF
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require("nvim-tree").setup()
EOF
Then in neovim: :PlugInstall.
But I'm far from being sure that this is a good solution.
On Windows VSCode ctrl+q shows a menu with the items on the activity bar.
What is that command?
I switch to Linux and want to add a key binding to that command (not map by default as on Linux ctrl+q quits the program) but cannot find it and don't have a Windows machine at hand to look on the key bindings and doesn't seem to be listed here.
When we do not have access to VSC on given platform
It should be possible to sift through the sources.
In this case we are looking for Ctrl that should be CtrlCmd and Q KeyQ in KEYBINDING of some module class, so something like:
static readonly ID = 'workbench.action.quickOpenView';
static readonly KEYBINDING = {
primary: KeyMod.CtrlCmd | KeyCode.KeyQ,
mac: { primary: KeyMod.WinCtrl | KeyCode.KeyQ },
linux: { primary: 0 }
};
(Yes, that's exactly it and I've started from here backwards.)
Slightly convoluted GitHub search query *
KEYBINDING KeyMod CtrlCmd KeyCode KeyQ repo:microsoft/vscode extension:ts
should bring us there so we now have the command ID: workbench.action.quickOpenView.
When we have VSC on platform at hand
It is easy as using the 'Record keys' feature in the Keyboard Shortcuts settings pane to find this information (either clicking the "Keyboard" icon or using Alt+K) where we should find that Ctrl+Q is by default bound to View: Quick Open View:
GitHub code search sadly ignores all non-alphanumerics
. , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ] #
In VS code editor, ng serve command opening "How do you want to open this file?" dialog box in
The answer by Petr Freiberg helped get me to what I believe is a better solution. Instead of deleting files that may or may not actually be important for the system, we should update our PATH variables so that the "correct" command is found first.
In my situation, I had my npm paths in this order:
C:\Users\Me\AppData\Roaming\npm\node_modules\#angular\cli\bin
C:\Users\Me\AppData\Roaming\npm
I just switched the order so that C:\Users\Me\AppData\Roaming\npm came first.
The issue is that the terminal is finding the first "command match" which may just be a file, so that is why it is asking where you want to open it.
I did run the command Run Get-Command -All ng | ForEach-Object Path as Petr suggested, which called out the order issue I describe here.
I encountered a similar problem when executing a Docker command within Visual Studio Code. I also got a window asking "How do you want to open this file?". I think the problem is not in Visual Studio Code, but in PowerShell, which Visual Studio Code uses.
I solved it like this:
Run Get-Command -All docker | ForEach-Object Path
Among the file paths returned, remove those that do not end in *.exe (use
Remove-Item):
For ng it should be same.
Credits: https://stackoverflow.com/a/63981418/1816014
i have faced the same issue, while trying to run ng -v or ng --version, it pops open a Open option editor, which gives following ng.js text...
#!/usr/bin/env node
'use strict';
// Provide a title to the process in `ps`.
// Due to an obscure Mac bug, do not start this title with any symbol.
try {
process.title = 'ng ' + Array.from(process.argv).slice(2).join(' ');
} catch (_) {
// If an error happened above, use the most basic title.
process.title = 'ng';
}
// This node version check ensures that extremely old versions of node are not used.
// These may not support ES2015 features such as const/let/async/await/etc.
// These would then crash with a hard to diagnose error message.
// tslint:disable-next-line: no-var-keyword
var version = process.versions.node.split('.').map((part) => Number(part));
if (version[0] % 2 === 1 && version[0] > 14) {
// Allow new odd numbered releases with a warning (currently v15+)
console.warn(
'Node.js version ' +
process.version +
' detected.\n' +
'Odd numbered Node.js versions will not enter LTS status and should not be used for production.' +
' For more information, please see https://nodejs.org/en/about/releases/.',
);
require('../lib/init');
} else if (
version[0] < 12 ||
version[0] === 13 ||
(version[0] === 12 && version[1] < 14) ||
(version[0] === 14 && version[1] < 15)
) {
// Error and exit if less than 12.14 or 13.x or less than 14.15
console.error(
'Node.js version ' +
process.version +
' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v12.14 or v14.15.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);
process.exitCode = 3;
} else {
require('../lib/init');
}
what is the error here, i tried uninstall clear cache and install but still same error....
I am a bit confused on how to save ipython alias so that everytime i open a ipython session(after saving alias firstly ) and use the alias command directly(at the point,you should not input the alias again ).
For example,when use ipython in linux(or windows) ,i would use vi rather than !vi a file .
vi fileneme
!vi filename
To generate the default configuration files ipython_config.py in your IPython directory under profile_default :
$ ipython profile create
Find ipython_config.py in linux/windows
#use find command in linux
find / -name ipython_config.py
#in window,you can use all kinds of tools to search .
#in commands line,you can use
ipython locate profile.
#in the directory,you can get it
Edit the ipython_config.py file to add the fellowing content
c = get_config()
c.TerminalIPythonApp.display_banner = True
c.InteractiveShellApp.log_level = 20
c.InteractiveShellApp.extensions = []
c.InteractiveShellApp.exec_lines = []
c.InteractiveShellApp.exec_files = ['mycode.py']#load Module when open ipython
c.InteractiveShell.autoindent = True
c.InteractiveShell.colors = 'LightBG'#ipython console color
c.InteractiveShell.confirm_exit = False
c.InteractiveShell.editor = 'vim'#you can change your favorite editor
c.InteractiveShell.xmode = 'Context'
c.PrefilterManager.multi_line_specials = True
#you can add your alias in the fellowing list
c.AliasManager.user_aliases = [('vi','vim'),('py','python'),('git','git'),]#i add git ,vim python .i really dislike "!"
Save the file and exit and get it
thx#jack yang
1.
emacs ~/.ipython/profile_default/python_config.py
2.in the end wirte down
c.AliasManager.user_aliases = [('e', 'emacsclient -t')]
3.exit and restart ipython
I'm trying to get vim set up as an IDE for Perl. I'm using generic, text-based vim, not gvim.
I installed the "vim-perl" addon at https://github.com/vim-perl/vim-perl using the vim addon manager per the suggestion of someone else. At least I think it's installed but I don't notice any difference in how the file is processed.
First I installed the vim-addon-manager with Debian's package manager. Then I put the following code in my .vimrc file and reloaded it:
" put this line first in ~/.vimrc
set nocompatible | filetype indent plugin on | syn on
fun! SetupVAM()
let c = get(g:, 'vim_addon_manager', {})
let g:vim_addon_manager = c
let c.plugin_root_dir = expand('$HOME', 1) . '/.vim/vim-addons'
" Force your ~/.vim/after directory to be last in &rtp always:
" let g:vim_addon_manager.rtp_list_hook = 'vam#ForceUsersAfterDirectoriesToBeLast'
" most used options you may want to use:
" let c.log_to_buf = 1
" let c.auto_install = 0
let &rtp.=(empty(&rtp)?'':',').c.plugin_root_dir.'/vim-addon-manager'
if !isdirectory(c.plugin_root_dir.'/vim-addon-manager/autoload')
execute '!git clone --depth=1 git://github.com/MarcWeber/vim-addon-manager '
\ shellescape(c.plugin_root_dir.'/vim-addon-manager', 1)
endif
" This provides the VAMActivate command, you could be passing plugin names, too
call vam#ActivateAddons([], {})
endfun
all SetupVAM()
" ACTIVATING PLUGINS
" OPTION 1, use VAMActivate
VAMActivate github:vim-perl/vim-perl
" OPTION 2: use call vam#ActivateAddons
"call vam#ActivateAddons([vim-perl], {})
use <c-x><c-p> to complete plugin names
" OPTION 3: Create a file ~/.vim-srcipts putting a PLUGIN_NAME into each line
" See lazy loading plugins section in README.md for details
" call vam#Scripts('~/.vim-scripts', {'tag_regex': '.*'})
So what exactly is the vim-perl addon supposed to do for me? I can't find any good documenation anywhere.
At least parts of vim-perl are incorporated in the factory-default configuration of Vim; cp. $VIMRUNTIME/ftplugin/perl.vim and $VIMRUNTIME/syntax/perl.vim. By installing (and regularly upgrading) the plugin, you'll get:
a newer version of the scripts, with potential enhancements and bug fixes
some additional functionality (f.e. there's a syntax/mason.vim that's not yet in Vim itself)
If you regularly edit non-trivial Perl scripts, or use latest language features, installing vim-perl is worth contemplating. If you're just a casual programmer, I would wait until a real need arises.