Neovim plugin for Fortran

Hello everyone! I made a simple lua plugin for making working with Fortran and it’s ecosystem of tools easier.

Quoting from the README.md for it’s features

  • Sets up fortls for you without any further configuration (customizable as well)
  • Integrates with fpm and provides a number of User Commands such as FpmRun, FpmBuild to run from within neovim instance
  • Integrates with fprettify and provides a command FpmFormat to format the whole document according to your options provided
  • optionally also sets up an autocmd to format the document on save
  • Sets the filetype of fypp files as appropriately, enabling the use of syntax highlighting and language server on such files.

It is quite new so I am not sure where I might’ve messed up, So Feature suggestions and Bug Reports are very much welcome! :grinning_face:

Do try it out, and let me know what you think!

7 Likes

Awesome ! I won’t be able to test it this weekend but I’ll definitely lazy-install it on Monday and take it for a test drive. I’ll be happy to give you any feedback once I’ve started to play around with it.

1 Like

on a separate issue, do you have a suggestion on how to get started with neovim ?

I’d say the best way if I were to do it now would be to learn the basics of lua and install kickstart.nvim and try to understand what the whole file and it’s individual parts are trying to do, and get used to reading :help pages… And once I am proficient in that, Install any distro (such as LazyVim, NvChad etc) temporarily and try to replicate it’s features that I find useful, taking inspiration from how it’s code is structured and which plugins it uses under the hood… And once you have your own working config you are of course free to explore new plugins of your own and tweak your config as much as you like. But of course I am assuming you are confident in vim motions (you can use Tutor to learn that and there are some nice youtube videos on this topic as well)

Another great reference I found that is not usually talked about is :h quickref, It is really handy to refer to, if you forget something on the go.

1 Like

kickstart.nvim is how I got started when transitioning from Emacs (yes, deep down I am from the Church of Emacs) as well. Really good. And even after almost two years now, I’ve actually modified its standard config file only incrementally.

(I am one of the three people in the world that still uses vim in lieu of neovim; I even converted my highly convoluted .vimrc to vim9)

If you’re not familiar with vim-like editors, the best way to start is by installing some kind of vim motions emulator in the editor/IDE you’re already familiar with —so that you avoid what I did: going from netbeans/eclipse to vim, from vim to atom, from atom to vim , from vim to Sublime, and then from Sublime to vim (for good).

The one for vscode is called “vim”.

After that, you can start exploring the things (neo)vim can do on its own without plugins.

I am one of those three too because I still use vim too haha I’ve moved to vscode with vim bindings for a C++ development project, but most of my other dev I still do in vim. Couple of coworkers use neovim and it looks promising, thanks for the advise!

Having found 2/3 people you were talking about, I am now curious about the last person haha :laughing:

1 Like

That’s very interesting, because, it looks like Neovim is the fullfilment of prophesy and divine elect for the continuation of tradition of vi->stevie->vim->. All glory to Vim for its long reign! :grin:
But seriously, to me Nvim makes sense (I have been a user since 2015). I am (respectfully) interested why some still choose Vim.

Did you use Doom Emacs? (Evil pagan) Or were you Orthodox :grin:.

I am secretly very jealous of Elisp. It is a beautiful language. But I am so happy that we got Lua in Neovim. There is so much practical value in it.

The question is interesting, mostly, because this is a Fortran forum —I mean, why using Fortran when MATLAB, Julia and Mojo will suffice? :laughing:

But seriously, Neovim started as a fork (because of a very time-consuming PR that never got merged), and the Lua part came after the fork. But that doesn’t mean Vim development stopped.

(Historically, some forks have overridden its original, like the GCC fork that eventually became the official GCC, or the OpenOffice.org soft fork that eventually became LibreOffice… but that’s not the case here.)

Eventually, Vim got the feature of the neglected PR, added embedded terminals and got inspiration from TypeScript for what would become vim9script.

So, if your .vimrc is simple enough, then Neovim will be a natural step forward. Otherwise, learning vim9script is not that bad.

I’m not averse to learning Lua (In my life, I think I’ve learned QBasic, Fortran, Pascal, Visual Basic 6, MATLAB, C, C++, Java, Python, Javascript, PHP, Go, C#, TypeScript… in that order), but simply haven’t had a need for it yet.

1 Like

It depended on my mood. I switched quite frequently between vanilla emacs, doom and spacemacs. Although spacemacs was a bit bloated, it was by far the easiest to get used to. I tried neovim out of curiosity two years ago. I forced myself to use it at least for two months to get a real feeling for how it works, and it just clicked. For the past two years, the only thing I still do in emacs is anything related to org-mode. Neovim support is not quite there although I do enjoy neorg.

2 Likes

Vim is great. One tip I can give is to just launch it via vi. That way whether it is neovim, or vim, I don’t need to change how I launch it from a terminal.

I use both neovim and vim, depending on what is installed on the system (I frequently use Linux, macOS and Windows). One issue with neovim is that if you install the lazygit plugins, it becomes slow and visibly lagging for me. I posted instructions here how to set it up with fortls: Exact instructions how to setup fortls with neovim · Issue #426 · fortran-lang/fortls · GitHub.

I also tested the Helix editor. It works well, does not lag, things just work. However they modified the vim keybindings and are not interested in supporting proper vim mode: Vim compatibility mode · Issue #5310 · helix-editor/helix · GitHub. So unfortunately that will not work for me.

Maybe after I finish the compiler, I will write an editor. Subset of vim, where LSP and other things just work, and it is fast. Never lagging. The issue is likely the use of lua, these basic features probably have to be part of the editor itself. Helix shows that it is possible.

1 Like

I don’t think neovim should be lagging that much to make it unusable, when I was new to the whole configuration thing, It was quite slow for me, like around 2 seconds startuptime but just adding these two lines

vim.loader.enable()
vim.g.loaded_python3_provider = 0

to the beginning of my init.lua significantly decreased my startuptime, by like 1-1.5 seconds.

And further using the features of lazy.nvim like loading the plugin at different events, ft, keys etc reduced it too, and it is around 35ms now (with 52 plugins).

nvim --startuptime time.log running this and manually inspecting the time.log file as to where it takes the most time helped me find out about these issues.

I tried helix and I think it is quite good, sometimes I use it when I get bored of nvim haha, but it takes some time to get adjusted to it’s different keybinds… there have been some forks of it adapting the keybinds to that of vim’s but I am not sure how well they keep up with the rapidly evolving main project.

I think your project idea would be quite interesting, I am ever ready to try out new terminal editors and maybe I would like to contribute to this one as well! :grinning_face:

1 Like

That is why I learned emacs back in the early 1980s. I was using unix, vax vms, and several other operating systems at that time, and emacs was the one that ran on the most of them. Of course, this was before MacOSX and Windows, and even some 15 or 20 years before linux, but emacs also ran on those when the time came. However, emacs has a large learning curve, and its scripting is based on the uncommon language lisp, so I understand why people hesitate to use it.

I tested what I consider “no lag”, and for a one time execution it is about 30ms. So 35ms is already too slow, but it’s close. For continuous movement, say holding a key and moving a cursor, the latency must go down to 5-10ms, then it looks “smooth”.

When I set nvim up last time with the plugins, it was relatively fast, just a fraction of a second to start, but more than 30ms for startup, and more than 10ms for movement, since I noticed a lag both times. And I don’t want any lag, it annoys me and distracts me. Computers are fast, I want things to be instant.

Awesome! It’s not going to be any time soon, first I will finish LFortran. Btw, the same principle applies there: small / medium projects should build instantly, and large projects (1M of lines) should take less than 1s. With our direct WASM backend (no LLVM), we are at around 0.25M lines / s, which is not a bad start, and I think maybe for some subset of Fortran (such as no preprocessor, no fancy & continuation lines, and only use declarations defined previously, so that we can just do one pass) it might be possible to get the speed up.

P.S. But you can start the editor project! :slight_smile:

1 Like