How to manually config nevim lsp and linter to make it smarter? - neovim

I'm switching from vscode to neovim (currently using lunarvim). One problem bothered me most is that if my included file don't use relative path, but handle these dependencies in Makefile instead, then the lsp failed to navigate, and make linter report mistakes because some definitions and declarations are in other files and can't be located.
I face the same situation in vscode too, but by writting c_cpp_properties.json file, the intellisense will work normally.
If there is any way to write down some hints for neovim lsp? Or maybe if there is some plugin that can auto detect the Makefile or CMakeList file and solve the problem?

Related

Indenting OCaml code in visual studio code

There are several questions here on indenting code in visual studio code (How do you format code in Visual Studio Code (VSCode)?), and on indenting OCaml code (How to indent existing OCaml code), but none of the answers work for indenting OCaml code in visual studio code.
I have installed the OCaml Platform visual studio code extension, vscode-ocaml-format (following https://dev.realworldocaml.org/install.html), ocaml-lsp-server (following https://ocaml.org/learn/tutorials/up_and_running.html) using opam, updated and upgraded everything, used eval $(opam env), but this still does not work. I'm a bit at a loss...
It is very hard to answer such questions as we need more debugging input from your side. On the other hand, it is so hard to get it from vscode so it is better just to walk you through the whole process from the very beginning to see where things might go wrong. I would suggest you follow the process for ease of debugging. After you have everything working you can adapt it to your particular setup.
Create a fresh new folder and put some OCaml file into it, let's name it test.ml and let's put into it the following code,
let test = [
"hello"
]
Now create a fresh local opam switch, by issuing in the same folder as the test.ml file the following command, (note the dot at the end of the command, it is required, it will create a local switch for you)
opam switch create .
Next install the required dependencies.
opam install ocamlformat ocamlformat-rpc ocaml-lsp-server
Create the .ocamlformat file in the same folder as the test.ml file. It will tell ocamlformat that you want to be ocamlformatted and you can use this file to setup your preferences.
Make sure that you have installed ocamlplatform for vscode
Now we are ready for the test. Start vscode and open test.ml. It will ask you to select the sandbox. Select the sandbox that corresponds to the folder where you put test.ml (it should be marked as local and have the same name as the folder name, and there will be the full path to it, so it will be easy for you to find it). The code syntax should be highlighted and there should be no error messages from vscode. Finally, hit Ctrl-Shift-I to re-indent your file, it should transform your code to,
let test = [ "hello" ]

How can I create a local configs for Neovim extending the global init.vim?

Suppose that I have a map on my init.vim that I want to change the behaviour depending on the folder that I am. How could you do that?
A more concrete example: I have a map on my F12 that runs the project that I am. So if I am on a python project, this F12 will run an ipython on a floaternew window, with the current file already imported. Though, if I am on a cpp project, the same F12 will build using Make and running the binary on a floaternew window as well.
Nowadays, I have these two behaviours mapped on different key bindings. But It is going to very nice if I have only one binding to "run the project". Even if I need to open neovim with some parameter in each project, like neovim --local-config mylocalconfig.vim (extending init.vim with some behaviour)
I am kind inspired by a behaviour like direnv but with .vim files.
Any ideas?
There is an option in vim set exrc which enables reading vim config files from current directory, it also works in neovim.
From docs (:h exrc)
Enables the reading of .vimrc, .exrc and .gvimrc in the current
directory. If you switch this option on you should also consider
setting the 'secure' option (see |initialization|). Using a local
.exrc, .vimrc or .gvimrc is a potential security leak, use with care!
also see |.vimrc| and |gui-init|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.

Couldn't start client ESLint message in VS Code

Recently I run into problem with ESlint extension in VS code. When I launch VS code and open up a js file, it popup message "Couldn't start client ESlint". It used to work fine. I tried to re-install eslint, VS code but it didn't help. Here are the versions I used.
VS code: 1.44.0 (user setup)
eslint: v6.8.0
ESLint Extension for VS code: 2.1.2
You need to dig a little bit more to get more details.
A good place to start would be to run the eslint show output command in VSCode. That should be a good starting point.
screenshot of ESLint: Show Output Command
The bottom line is that you need to follow the conventional installation path:
add eslint extension in vscode.
install eslint locally or globally via npm,
run eslint init in your project path and select proper configurations.
restart vscode just to make sure the settings are active.
again, the eslint output console should be a good starting point.
For me, it turns out I had the eslint.runtime and eslint.nodePath settings set to the specified node path on my system, but they were prefixed like this:
~/.nvm/versions/node/v14.17.0/bin/node
Using $HOME instead of ~ didn't solve it either.
I ended up having to specify an absolute path:
/home/<myusername>/.nvm/versions/node/v14.17.0/bin/node

Flutter VSCode intellisense not working for single file packages

The VSCode Intellisense doesn't provide any suggestions for any single file packages in Flutter.
I've tried this on my own plugin as well as the Webview plugin
https://pub.dev/packages/webview_flutter
However, the Intellisense works if the package is created like this (library keyword is used) -
library nearby_connections;
export 'src/classes.dart';
export 'src/defs.dart';
export 'src/nearby_connections.dart';
Is this some issue via VSCode, can I resolve it somehow by changing some configurations?
Opening a loose file is not currently supported (see https://github.com/Dart-Code/Dart-Code/issues/602), you need to open a folder. In the latest version of the Dart extension for VS Code, a warning will be shown if you do this explaining how to resolve it.

How to invoke F# auto-completion in Emacs

I installed FSharp 3.1, Emacs 24 and fsharp-mode of emacs. Howerver the auto-completion feature (complete-at-point) didn't work. I followed all the instructions here https://github.com/fsharp/fsharpbinding/blob/master/emacs/README.md and added fsautocomplete.exe to my $PATH .
But it still didn't work.
PS:
I failed in Debian sid, Ubuntu Trusty and Mac 10.9.
I am the author. In order to have autocomplete in fsharp-mode, you must either be editing a script (.fsx) file, or a normal (.fs) file that is associated with a project (.fsproj) file.
If a .fs file is opened and no other project has already been loaded, then fsharp-mode will look for and load a .fsproj in the current and enclosing directories. This can be done manually using C-c C-p. At this point autocompletion will be available in all .fs files mentioned in the project.
If a project has not been loaded, then no autocompletion will be available in .fs files.
I tried to make this clear in the README.md. I'll have a look updating it, and trying to give feedback in the interface as to why autocompletion is not available.
The author gave me the solution that the .fs file must be in the same directory with the .fsproject relating to it.