Skip to content

Setup

We have specific setup instructions depending on your editor of choice. If you don't see your editor on this list and would like a setup guide, please open an issue.

Note

The setup instructions provided below are on a best-effort basis. If you encounter any issues while setting up the Fortitude in an editor, please open an issue for assistance and help in improving this documentation.

VS Code

Warning

The VS Code extension is experimental and not yet published!

For more documentation on the Fortitude extension, refer to the README of the extension repository.

Neovim

The nvim-lspconfig plugin can be used to configure the Fortitude Language Server in Neovim. To set it up, install nvim-lspconfig plugin, set it up as per the configuration documentation, and add the following to your init.lua:

require('lspconfig').fortitude.setup({
  init_options = {
    settings = {
      -- Fortitude language server settings go here
    }
  }
})
vim.lsp.config('fortitude', {
  cmd = { "fortitude", "server" },
  filetypes = { "fortran" },
  root_markers = { 'fpm.toml', 'fortitude.toml', '.fortitude.toml', '.git', 'pyproject.toml' },
  single_file_support = true,
  init_options = {
    settings = {
      -- Fortitude language server settings go here
    }
  }
})

vim.lsp.enable('fortitude')

If you're using Fortitude alongside another language server (like fortls), you may want to defer to that language server for certain capabilities, like textDocument/hover:

vim.api.nvim_create_autocmd("LspAttach", {
  group = vim.api.nvim_create_augroup('lsp_attach_disable_fortitude_hover', { clear = true }),
  callback = function(args)
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    if client == nil then
      return
    end
    if client.name == 'fortitude' then
      -- Disable hover in favor of fortls
      client.server_capabilities.hoverProvider = false
    end
  end,
  desc = 'LSP: Disable hover capability from Fortitude',
})

By default, the log level for Fortitude is set to info. To change the log level, you can set the logLevel setting:

require('lspconfig').fortitude.setup {
  init_options = {
    settings = {
      logLevel = 'debug',
    }
  }
}

By default, Fortitude will write logs to stderr which will be available in Neovim's LSP client log file (:lua vim.print(vim.lsp.get_log_path())). It's also possible to divert these logs to a separate file with the logFile setting.

To view the trace logs between Neovim and Fortitude, set the log level for Neovim's LSP client to debug:

vim.lsp.set_log_level('debug')
With the nvim-lint plugin for Neovim.
require("lint").linters_by_ft = {
  fortran = { "fortitude" },
}
With the ALE plugin for Neovim or Vim. Neovim (using Lua):
-- Linters
vim.g.ale_linters = { fortran = { "fortitude" } }
Vim (using Vimscript):
" Linters
let g:ale_linters = { "fortran": ["fortitude"] }

Vim

The vim-lsp plugin can be used to configure the Fortitude Language Server in Vim. To set it up, install vim-lsp plugin and register the server using the following in your .vimrc:

if executable('fortitude')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'fortitude',
        \ 'cmd': {server_info->['fortitude', 'server']},
        \ 'allowlist': ['fortran'],
        \ 'workspace_config': {},
        \ })
endif

See the vim-lsp documentation for more details on how to configure the language server.

If you're using Fortitude alongside another LSP (like fortls), you may want to defer to that LSP for certain capabilities, like textDocument/hover by adding the following to the function s:on_lsp_buffer_enabled():

function! s:on_lsp_buffer_enabled() abort
    " add your keybindings here (see https://github.com/prabirshrestha/vim-lsp?tab=readme-ov-file#registering-servers)

    let l:capabilities = lsp#get_server_capabilities('fortitude')
    if !empty(l:capabilities)
      let l:capabilities.hoverProvider = v:false
    endif
endfunction
Fortitude can also be integrated via efm language server in just a few lines. Following is an example config for efm to use Fortitude for linting Fortran files:
tools:
  fortran-fortitude:
    lint-command: "fortitude check --stdin-filename ${INPUT} --output-format concise --quiet -"
    lint-stdin: true
    lint-formats:
      - "%f:%l:%c: %m"

Helix

Open the language configuration file for Helix and add the language server as follows:

[language-server.fortitude]
command = "fortitude"
args = ["server"]

Then, you'll register the language server as the one to use with Fortran. If you don't already have a language server registered to use with Fortran, add this to languages.toml:

[[language]]
name = "fortran"
language-servers = ["fortitude"]

Otherwise, if you already have language-servers defined, you can simply add "fortitude" to the list. For example, if you already have fortls as a language server, you can modify the language entry as follows:

[[language]]
name = "fortran"
language-servers = ["fortitude", "fortls"]

Note

Support for multiple language servers for a language is only available in Helix version 23.10 and later.

See the Helix documentation for more settings you can use here.

You can pass settings into fortitude server using [language-server.fortitude.config.settings]. For example:

[language-server.fortitude.config.settings]
lineLength = 80

[language-server.fortitude.config.settings.check]
select = ["correctness", "S001"]
preview = false

By default, the log level for Fortitude is set to info. To change the log level, you can set the logLevel setting:

[language-server.fortitude]
command = "fortitude"
args = ["server"]

[language-server.fortitude.config.settings]
logLevel = "debug"

You can also divert Fortitude's logs to a separate file with the logFile setting.

To view the trace logs between Helix and Fortitude, pass in the -v (verbose) flag when starting Helix:

hx -v path/to/file.f90

Kate

  1. Activate the LSP Client plugin.
  2. Setup LSP Client as desired.
  3. Finally, add this to Settings -> Configure Kate -> LSP Client -> User Server Settings:
{
  "servers": {
    "fortran": {
      "command": ["fortitude", "server"],
      "url": "https://github.com/PlasmaFAIR/fortitude",
      "highlightingModeRegex": "^Fortran$",
      "settings": {}
    }
  }
}

See LSP Client documentation for more details on how to configure the server from there.

Important

Kate's LSP Client plugin does not support multiple servers for the same language.

Sublime Text

To use Fortitude with Sublime Text, install Sublime Text's LSP and open Preferences > Package Settings > LSP > Settings and add the fortitude configuration to the "clients":

{
  "clients": {
    "fortitude-lsp": {
      "enabled": true,
      "command": ["/home/peter/Codes/fortitude/target/release/fortitude", "server"],
      "selector": "source.fortran | source.modern-fortran"
    }
  }
}

Emacs

Fortitude can be utilized as a language server via Eglot, which is in Emacs's core:

(add-hook 'f90-mode-hook 'eglot-ensure)
(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               '(f90-mode . ("fortitude" "server"))))

You can also use Fortitude in lsp-mode:

(lsp-register-client
 (make-lsp-client
  :new-connection (lsp-stdio-connection '("fortitude" "server"))
  :activation-fn (lsp-activate-on "fortran")
  :server-id 'fortitude
  :priority -2
  :add-on? t))

Zed

  1. Install the Zed fortitude extension
  2. Add fortitude as language server in your settings. For instance, if you want to use it along fortls (highly recommended):
{
  "languages": {
    "Fortran": {
      "language_servers": ["fortls", "fortitude"]
    },
  }
}