When developing F#, there is a nice selection of quality development environments to choose from. One option that is often overlooked is Vim. IDEs have some really nice functionality, but often I just need a good editor with the right plug-ins. When it comes down to it, I’ll use whatever tools are necessary to get the job done. But all things being equal, the more I can live in Vim, generally the happier I am. The Vim muscle-memory built up over time has a strong pull toward a level of efficiency. So for anyone who falls into that category, this is for you.
Like most vim-addicts, I have my beloved set of plug-ins and customizations to enhance my general working environment. Although I can drone on about those, today I want to focus on a couple plug-ins that are specific to F#. The first, and most obvious is Ionide-Vim. It is a sibling of the VSCode Ionide extension for F# (which is awesome btw). Like it’s relative, this leverages FSAutoComplete for a backend to provide the typical intellisense and context aware code navigation that most developers are acustom to. Currently it leverages an LSP plug-in for integration into Vim. Not to dig into configuration too much, but I use Plug, and I added some mappings I do to better leverage Ionide and LSP functionality. The relative parts of my vim config looks like below.
1 | Plug 'autozimu/LanguageClient-neovim', { |
Additionally, snipmate and snippets are great for some simple snippet expansion. If you’re not familiar with snippets, they are predefined code blocks (sometimes templated) that allow for quick expansion based on keywords. It’s a small optimization, but it reduces some tedious typing. The solution here is two parts. One, snipmate provides the funationality of snippet expansion. Two, snippets is a aggregation of user-provided language-specific snippets. You can write your own (and I do), but the repo provides a strong jumping-off point if you just want to get started.
1 | Plug 'tomtom/tlib_vim' |
Sometimes I need to whip up a quick .fsx script. There is some typical boiler-plate I like to include. I could copy a file, but I found it’s a lot easier to leverage vim templates. Below is my current template, vim takes care of the rest. The way it works is if you open a new file in vim and a template exists for the filetype, vim will populate the buffer with the template file. If I open a new file, like foo.fsx
, instead of being empty, it’s populated with the template file. Again, it is one of these small optimizations that helps me get into the code I care about faster. File: ~/.vim-templates/template.fsx
1 | #!/usr/bin/env -S dotnet fsi |
Along with my other vim plug-ins and customizations, these F#-specific addtitions go a long way to making F# development in Vim a enjoyable experience. Hopefully you found something useful to make your experience better as well. Thanks, and happy vimming!
:wq