Skip to content

feat(lang): julia support#6231

Merged
folke merged 1 commit intoLazyVim:mainfrom
storopoli:feat/lang/julia
Oct 20, 2025
Merged

feat(lang): julia support#6231
folke merged 1 commit intoLazyVim:mainfrom
storopoli:feat/lang/julia

Conversation

@storopoli
Copy link
Contributor

Description

Related Issue(s)

#5455

Screenshots

CleanShot 2025-07-05 at 08 05 01@2x

Checklist

- Another take on LazyVim#4436.
- Adds LSP
- Adds cmp and blink.cmp for LaTeX symbols
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

This PR is stale because it has been open 30 days with no activity.

@github-actions github-actions bot added the stale This issue or PR has been inactive for a while label Aug 5, 2025
@frankier
Copy link
Contributor

frankier commented Aug 24, 2025

Looks good!

I foresee two small problems. One is that the default config formats on save by default, but Julia formatting is quite up in the air at the moment. JuliaLanguageServer.jl is stuck on JuliaFormatter.jl 1.x, which breaks valid Julia such as using the public statement, while 2.x is quite unstable. There's also Runic.jl which is a bit more stable, but much less popular.

Since this is a bit of a trap, and there's no canonical option, I propose to just disable formatting by default, and users can opt-in to the formatter they want instead.

  {
    "stevearc/conform.nvim",
    optional = true,
    opts = {
      formatters_by_ft = {
        julia = { lsp_format = "never" },
      },
    },
  },

The other thing to note is that enabling https://github.com/kdheepak/cmp-latex-symbols for all file types might be a bit annoying. Ideally it would only be enabled for Julia by default since it clutters up the completions for other languages, and is actively harmful for LaTeX -- where it will replace LaTeX commands with Unicode symbols which won't work in many common LaTeX environments. Unfortunately the recommended way of doing this https://cmp.saghen.dev/recipes.html#dynamically-picking-providers-by-treesitter-node-filetype seems like it won't work well with settings inheritance. Perhaps this could be added to the blink.cmp spec? Or else something programmatic comparable to hrsh7th/nvim-cmp#666 (comment) (which is from nvim-cmp not blink.cmp -- but maybe it could be adapted). Any thoughts?

@github-actions github-actions bot removed the stale This issue or PR has been inactive for a while label Aug 25, 2025
@frankier
Copy link
Contributor

Actually for the second one I suppose that just adding ft="julia" should do the trick.

@frankier
Copy link
Contributor

I'm not sure why, but whatever I do, I'm not able to blacklist the LSP formatter altogether (advice welcome). In the end I just added this to my autocmds.lua:

local set_autoformat = function(pattern, bool_val)
  vim.api.nvim_create_autocmd({ "FileType" }, {
    pattern = pattern,
    callback = function()
      vim.b.autoformat = bool_val
    end,
  })
end

set_autoformat({ "julia" }, true)

Cribbed from here: #141 (reply in thread)

Not sure how to blacklist the LSP formatter, or what would be best for an extra. I guess something like this could be adapted? #6173 (comment)

@dpetka2001
Copy link
Contributor

dpetka2001 commented Aug 25, 2025

@frankier Yes, LazyVim registers its own LSP formatter. I believe the only option to disable it is to either implement the suggestion in #6173 for a global solution or to explicitly set the format handlers in each LSP server to just empty function that don't return anything.

I don't know why maintainer made this decision, since conform.nvim also has the ability to fallback to LSP formatting. That is a question better forwarded to him.

I believe we could also change here

local ret = vim.tbl_filter(function(client)
return client.supports_method("textDocument/formatting")
or client.supports_method("textDocument/rangeFormatting")
end, clients)
into

      local ret = vim.tbl_filter(function(client)
        return (
          client.supports_method("textDocument/formatting")
          or client.supports_method("textDocument/rangeFormatting")
        ) and client.config.capabilities.textDocument.formatting ~= false
      end, clients)

and then people could do in their personal configuration something like

lua_ls = {
  capabilities = {
    textDocument = {
      formatting = false,
    },
  },
}

to disable the LSP formatting for a specific LSP server. But I'm not confident if that causes any other side-effects, so it would be up to maintainer as to how better implement this. Code taken from this commit where such an option existed in the past before the transition to conform.nvim and LazyVim's explicit LSP formatter.

Edit: changed to use client capabilities corresponding fields instead of server capability documentFormattingProvider.

@frankier
Copy link
Contributor

Thanks for the explanation! I wonder too... Perhaps an oversight? I agree we need input from folke for a proper solution.

@frankier
Copy link
Contributor

frankier commented Sep 4, 2025

This is what I've ended up at for the LaTeX symbols:

  {
    "https://gitlab.com/ExpandingMan/cmp-latex",
    ft = "julia",
    init = function()
      -- cmp integration
      vim.api.nvim_create_autocmd("FileType", {
        pattern = "julia",
        callback = function()
          if LazyVim.has_extra("coding.nvim-cmp") then
            local cmp = require("cmp")

            -- global sources
            ---@param source cmp.SourceConfig
            local sources = vim.tbl_map(function(source)
              return { name = source.name }
            end, cmp.get_config().sources)

            -- add latex_symbols source
            table.insert(sources, { name = "latex_symbols" })

            -- update sources for the current buffer
            cmp.setup.buffer({ sources = sources })
          end
        end,
      })
    end,
  },

  -- cmp integration
  {
    "hrsh7th/nvim-cmp",
    optional = true,
    dependencies = { "cmp-latex" },
  },

  -- blink.cmp integration
  {
    "saghen/blink.cmp",
    optional = true,
    dependencies = { "cmp-latex", "saghen/blink.compat" },
    opts = {
      sources = {
        per_filetype = {
          julia = { inherit_defaults = true, "latex_symbols" },
        },
        providers = {
          latex_symbols = {
            name = "latex_symbols",
            module = "blink.compat.source",
            async = true,
            score_offset = 200,
          },
        },
      },
    },
  },

I use https://gitlab.com/ExpandingMan/cmp-latex since it works exactly like the Julia REPL. Then it turns out it to be a fit of a faff to restrict the suggestions to Julia, but this leaves my LaTeX files unicode free as is sometimes needed.

@folke folke added the size/l Large PR (<100 lines changed) label Oct 19, 2025
@folke folke merged commit 5d186c0 into LazyVim:main Oct 20, 2025
9 checks passed
@folke
Copy link
Collaborator

folke commented Oct 20, 2025

ty

folke pushed a commit that referenced this pull request Oct 20, 2025
🤖 I have created a release *beep* *boop*
---


##
[15.10.0](v15.9.0...v15.10.0)
(2025-10-20)


### Features

* **ai:** add avante.nvim for a better AI experience
([#4440](#4440))
([2682ce0](2682ce0))
* **extra:** allow users to add custom bundles through
opts.init_options.bundles to jdtls
([#6265](#6265))
([faeb24b](faeb24b))
* **extras:** add Dart language
([#4749](#4749))
([90f84e7](90f84e7))
* **extras:** added ember lang support
([#6203](#6203))
([ac4cce0](ac4cce0))
* **extras:** added twig language
([#5464](#5464))
([a6eb51e](a6eb51e))
* **extras:** ai: add `claudecode.nvim`
([#6229](#6229))
([e7a3e80](e7a3e80))
* **extras:** automatically update lazyvim.json for renamed or
deprecated extras
([37ecd06](37ecd06))
* **extras:** renamed extra omnisharp -&gt; dotnet + added fautocomplete
to lspconfig
([1b2e6e8](1b2e6e8))
* **extras:** utils: add `gh.nvim`
([#6250](#6250))
([8db9c75](8db9c75))
* **go:** add linting with golangci-lint
([#6311](#6311))
([248876a](248876a))
* **haskell:** update `haskell-tools` version and add formatters +
linters ([#6230](#6230))
([82382f4](82382f4))
* **lang/fsharp:** add F# support to omnisharp extra
([#6538](#6538))
([80a980a](80a980a))
* **lang:** add neotest config for PHP tests
([#5958](#5958))
([9b077c7](9b077c7))
* **lang:** add solidity language support
([#4742](#4742))
([2cd46d4](2cd46d4))
* **lang:** add Typst language support
([#4042](#4042))
([645846b](645846b))
* **lang:** julia support
([#6231](#6231))
([5d186c0](5d186c0))
* **lang:** nix add `statix` linter
([#6244](#6244))
([2a866f6](2a866f6))
* **sidekick:** added sidekick cli status to lualine
([16917db](16917db))


### Bug Fixes

* **extras.lang:** fix Scala extra by using nvimMetals only
([#5726](#5726))
([f118dca](f118dca))
* **fzf-lua:** added some missing keymaps similar to snacks picker.
Closes [#6036](#6036). Closes
[#5830](#5830)
([69a5744](69a5744))
* **helm:** broken helm highlighting
([#5335](#5335))
([4d0d87f](4d0d87f))
* **keymap:** remove select mode remaps of printable characters
([#6296](#6296))
([83468be](83468be))
* **tailwind:** additional settings
([#5266](#5266))
([d2f9885](d2f9885))
* **telescope:** sync keymaps with snacks picker + added some that were
missing
([1a08e9f](1a08e9f))
* **twig:** correct mason url
([9d345de](9d345de))
* **typescript:** better default pwa-node DAP config. Closes
[#6386](#6386)
([e4d3432](e4d3432))
* **typescript:** support chrome, node and msedge dap adapters
([#6649](#6649))
([0b65d33](0b65d33))
* **util.project:** different mapping on dashboard than
`snacks.projects`
([#5737](#5737))
([e389447](e389447))


### Reverts

* "feat(extra): allow users to add custom bundles through
opts.init_options.bundles to jdtls
([#6265](#6265))"
([#6650](#6650))
([a582f00](a582f00))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
NanoBoom pushed a commit to NanoBoom/LazyVim that referenced this pull request Oct 21, 2025
🤖 I have created a release *beep* *boop*
---


##
[15.10.0](LazyVim/LazyVim@v15.9.0...v15.10.0)
(2025-10-20)


### Features

* **ai:** add avante.nvim for a better AI experience
([#4440](LazyVim/LazyVim#4440))
([2682ce0](LazyVim/LazyVim@2682ce0))
* **extra:** allow users to add custom bundles through
opts.init_options.bundles to jdtls
([#6265](LazyVim/LazyVim#6265))
([faeb24b](LazyVim/LazyVim@faeb24b))
* **extras:** add Dart language
([#4749](LazyVim/LazyVim#4749))
([90f84e7](LazyVim/LazyVim@90f84e7))
* **extras:** added ember lang support
([#6203](LazyVim/LazyVim#6203))
([ac4cce0](LazyVim/LazyVim@ac4cce0))
* **extras:** added twig language
([#5464](LazyVim/LazyVim#5464))
([a6eb51e](LazyVim/LazyVim@a6eb51e))
* **extras:** ai: add `claudecode.nvim`
([#6229](LazyVim/LazyVim#6229))
([e7a3e80](LazyVim/LazyVim@e7a3e80))
* **extras:** automatically update lazyvim.json for renamed or
deprecated extras
([37ecd06](LazyVim/LazyVim@37ecd06))
* **extras:** renamed extra omnisharp -&gt; dotnet + added fautocomplete
to lspconfig
([1b2e6e8](LazyVim/LazyVim@1b2e6e8))
* **extras:** utils: add `gh.nvim`
([#6250](LazyVim/LazyVim#6250))
([8db9c75](LazyVim/LazyVim@8db9c75))
* **go:** add linting with golangci-lint
([#6311](LazyVim/LazyVim#6311))
([248876a](LazyVim/LazyVim@248876a))
* **haskell:** update `haskell-tools` version and add formatters +
linters ([#6230](LazyVim/LazyVim#6230))
([82382f4](LazyVim/LazyVim@82382f4))
* **lang/fsharp:** add F# support to omnisharp extra
([#6538](LazyVim/LazyVim#6538))
([80a980a](LazyVim/LazyVim@80a980a))
* **lang:** add neotest config for PHP tests
([#5958](LazyVim/LazyVim#5958))
([9b077c7](LazyVim/LazyVim@9b077c7))
* **lang:** add solidity language support
([#4742](LazyVim/LazyVim#4742))
([2cd46d4](LazyVim/LazyVim@2cd46d4))
* **lang:** add Typst language support
([#4042](LazyVim/LazyVim#4042))
([645846b](LazyVim/LazyVim@645846b))
* **lang:** julia support
([#6231](LazyVim/LazyVim#6231))
([5d186c0](LazyVim/LazyVim@5d186c0))
* **lang:** nix add `statix` linter
([#6244](LazyVim/LazyVim#6244))
([2a866f6](LazyVim/LazyVim@2a866f6))
* **sidekick:** added sidekick cli status to lualine
([16917db](LazyVim/LazyVim@16917db))


### Bug Fixes

* **extras.lang:** fix Scala extra by using nvimMetals only
([#5726](LazyVim/LazyVim#5726))
([f118dca](LazyVim/LazyVim@f118dca))
* **fzf-lua:** added some missing keymaps similar to snacks picker.
Closes [#6036](LazyVim/LazyVim#6036). Closes
[#5830](LazyVim/LazyVim#5830)
([69a5744](LazyVim/LazyVim@69a5744))
* **helm:** broken helm highlighting
([#5335](LazyVim/LazyVim#5335))
([4d0d87f](LazyVim/LazyVim@4d0d87f))
* **keymap:** remove select mode remaps of printable characters
([#6296](LazyVim/LazyVim#6296))
([83468be](LazyVim/LazyVim@83468be))
* **tailwind:** additional settings
([#5266](LazyVim/LazyVim#5266))
([d2f9885](LazyVim/LazyVim@d2f9885))
* **telescope:** sync keymaps with snacks picker + added some that were
missing
([1a08e9f](LazyVim/LazyVim@1a08e9f))
* **twig:** correct mason url
([9d345de](LazyVim/LazyVim@9d345de))
* **typescript:** better default pwa-node DAP config. Closes
[#6386](LazyVim/LazyVim#6386)
([e4d3432](LazyVim/LazyVim@e4d3432))
* **typescript:** support chrome, node and msedge dap adapters
([#6649](LazyVim/LazyVim#6649))
([0b65d33](LazyVim/LazyVim@0b65d33))
* **util.project:** different mapping on dashboard than
`snacks.projects`
([#5737](LazyVim/LazyVim#5737))
([e389447](LazyVim/LazyVim@e389447))


### Reverts

* "feat(extra): allow users to add custom bundles through
opts.init_options.bundles to jdtls
([#6265](LazyVim/LazyVim#6265))"
([#6650](LazyVim/LazyVim#6650))
([a582f00](LazyVim/LazyVim@a582f00))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extras extras-lang size/l Large PR (<100 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants