NeoVim not loading init.vim file - neovim

I just installed Neovim and created a simple init.vim file (located at HOME/.config/nvim/init.vim), and when I do :source % the script works, but when I exit and reopen Neovim, the file doesn't get loaded and I get the normal Neovim without the configurations I added to the file... How can I let Neovim load init.vim?

Try to run Neovim with -V option, which will dump the startup log to the given file:
nvim -V /tmp/nvim.log
Then open the created log file and carefully read the lines. It's hard to say what could be wrong there, but you may see which configuration files were loaded and, perhaps, the warnings when reading some files.
For example, my log file contains the following line:
continuing in /home/jubnzv/.config/nvim/init.vim
Which mean that init.vim was loaded.
Try to find the similar line in your log. If you don't see it, please check the filepath and permissions for the configuration file.

If you are on Linux based OS then init.vim or init.lua file should be under $HOME/.config/NVIM/init.vim
In windows OS it should be under
C:\Users\filip\AppData\Local\nvim\init.vim
:source % Works because it forces NVIM to source file opened in current buffer.

In MacOS I found the following error after running nvim -V /tmp/nvim.log(as in #jubnzv's answer):
E5422: Conflicting configs: "/Users/lernerzhang/.config/nvim/init.lua" "/Users/lernerzhang/.config/nvim/init.vim"
Then I kept the init.vim and deleted init.lua, and moved the content of init.lua file to ~/.config/nvim/lua/config.lua and sourced the config.lua file in init.vim by adding this line into it:
lua require('config')

Related

Cannot change read/write permissions on script file /usr/local/bin code

So I recently updated my Mac to iOS Ventura. Since then I am unable to type "code ." into my terminal to open vs code in whatever directory I am in. The error I get is:
/usr/local/bin/code: line 6: python: command not found /usr/local/bin/code: line 10: ./MacOS/Electron: No such file or directory
I saw a solution here and the same one somewhere else.
However, when I try was in /usr/local/bin and typed "nano code" I was unable to edit the file. I got the error [ cannot open file for writing: read-only file system ]. I also tried dragging the file into VS code but I had a similar read/write issue. I am also unable to edit the permissions when I right click on the file and hit "get info". There is no option to edit. I also tried changing the permissions on that file using chmod to no avail. It's driving me nuts that I don't have read/write permission for files on my own computer. Does anyone have an idea of how I can have writing permissions on this file?
I do know for the /usr/local/bin/code: line 6: python: command not found you can run sudo vim /usr/local/bin/code and then add 3 to the end of python on this line function realpath() { python<3> -c "import... I guess the new mac update does not support python 2 anymore so you have to specify 3. Still looking into the line 10 error. If I figure it out I will post here again.

Swift on Ubuntu 20.04- Need to add a path every time

I am simply trying to install swift on linux
I have downloaded the files from swift.org, extracted .tar files and used export command to include the path after that when I use swift --version it correctly shows the version 5.3.3 but when I close the terminal and try to open the swift command terminal it says command not found.
What is happening here? I need to include the path every time I open the terminal.
The export command just adds the value to path for the current session. When you log out and in again, it will reset.
You need to add this to your shell resource file so that it gets added to the path every time you log in. The file you need to edit will be called .zshrc or .bash_profile or something similar. You should start by opening the command line on your computer and verifying what shell you are running by typing:
echo $SHELL
This will return something like /bin/ksh or /bin/bash or similar. Then do a little internet searching to find out what the resource file is called for that shell. Then edit your resource file to add the Swift path to your $PATH.

Flutter commands not working in the Terminal

I have downloaded flutter and completed my setup am sure its good as I have checked it 5 times and put the correct file path export PATH="$PATH:/Users/KingKimani/Developer/flutter/bin". but I can't run flutter doctor or any flutter command why?
I am currently using the MAC M1 chip.
If you are using zsh do the following.
Open .zshrc file nano $HOME/.zshrc
You will see the commented $PATH variable here
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/...
Remove the comment symbol(#) and append your new path using a separator(:) like this.
export PATH=$HOME/bin:/usr/local/bin:/Users/KingKimani/Developer/flutter/bin:$PATH
Activate the change
source $HOME/.zshrc
You're done !!!
After setting the correct path on the system.
System terminal needs to have latest environment configurations.
Restart/Reload terminal required.
If you are using zsh shell & have save path on .zshrc file.
below command will reload configurations
source ~/.zshrc
Reference

Set Permanent Flutter Path

The steps for modifying this variable permanently for all terminal sessions are machine-specific. Typically you add a line to a file that is executed whenever you open a new window. For example:
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile. The file path and filename might be different on your machine.
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:
$ export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
Run source $HOME/.bash_profile to refresh the current window.
Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
In mac, you should add it as follows in ".zshrc":
export PATH="$PATH:/Users/matteo/Documents/flutter/bin"
After you have updated the ".zshrc" file, run this command to ensure changes have been notified to OS
source ~/.zshrc
Reference: https://flutter.dev/docs/get-started/install/macos
A similar concept is for Linux system using bash files
I tried a lot of methods but this one permanent solution worked for me like a charm:
open Terminal in your Mac: type:
sudo nano /echo/paths
Add the code to the file:
/users/yourUserName/flutter/bin
Save the file using Control+X and Press Y and Enter
Hope this helps! :)

Convert ipynb to pdf in Jupyter

I am new to ipython notebook, and I would like to convert my ipynb to pdf. But I get the following error when I try to Download as PDF via LaTex.
nbconvert failed: pdflatex not found on PATH
There is no documentation anywhere how to add pdflatex to my PATH. I use windows. Thank you!
A simple and surprisingly good solution is to print the notebook to pdf through the browser with ctrl+p. Just make sure your plots and figures are not on interactive mode otherwise they will not be displayed (set them to %matplotlib inline).
Exporting jupyter notebooks through latex is quite troublesome and takes a lot of tinkering to get something remotely close to publish ready. When I absolutely need publication quality I do it on a latex editor, but this tutorial goes in great length about doing it on jupyter.
A few useful tips to get better results:
Higher resolution plots
Hide your code-cells from the pdf
Take a look at these extensions to improve your jupyter documents
For Mac OS X, the solution for me was to install MacTex first and then export the path to find it:
### TeX
export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
You can add this to your .bash_profile or similar config file to load it every time.
See more here https://github.com/jupyter/nbconvert/issues/406
As said by Thomas K in the comments, you need to have Latex installed, and after add the path to the directory containing pdflatex.exe file to the PATH variable of your system.
I have looked for a lightweight distribution and tried installing TeXworks, but I didn't find any pdflatex.exe file.
So I have tried TeX Live, which worked fine creating the pdflatex.exe file under the target installation directory. This path should be like C:\...\texlive\2016\bin\win32.
Finally, you should just add this path to the PATH environment variable of your system (you can use the link shared by Thomas K).
As said here, you need to quit jupyter notebook and open a new command prompt after making any path changes, in order for jupyter to find the newly added item to the PATH.
Then, in Jupyter, you can check your environment variables by running the following (refer to this link for details):
import os
os.environ['PATH'].split(';')
and check if it contains the path to pdflatex.exe file.
If you get some trouble when exporting your notebook to pdf due to missing files/packages (this happened to me), refer to this link to search and install them under TeX Live.
For Linux, the reported error is due to the lack of XeLatex, part of the texlive-xetex package.
Installation in ubuntu will be:
sudo apt install texlive-xetex
Instead of using nbconvert what you can do is :
Download your ipynb file as HTML from File option.
Right-click and select print or use Ctrl+P.
Save as PDF
Easy.
Here is the full solution that worked for me (for Mac).
brew cask install mactex
$ cd ~/
$ touch .bash_profile
This will open the bash profile on TextEditor
$ open -e .bash_profile
Paste the following to the top and save
export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
Close any notebook you have and reopen it
Here is the notebook explaining it step by step:
https://github.com/ybaktir/notes/blob/master/Convert%20Jupyter%20Notebook%20to%20Pdf.ipynb
I agree that latex installation (at least on windows) is painful and the result in my case was not a great looking document. The ctrl-p method alone doesn't work great if you're running in JupyterLab, but if you export the notebook to HTML, then print from the browser, choosing PDF, the result is quite good.
I know my solution is not at a level. But it works !!
in your browser of notebook tab, simply do "ctrl + p" to get download in pdf
First export the notebook file to HTML (available through File> Download as..).
If you are using JupyterLab, then this is available under File > Export Notebook As....
Use (any) free online converters to convert html file to a pdf file. (One such free online converter is sejda (https://www.sejda.com/html-to-pdf)
Note, there are many such converters are available online.