From 71aa9b4c2b7c5db4daabf7d3d3c3ba8ff7e918f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Wed, 15 Oct 2025 22:56:13 +0200 Subject: [PATCH 01/11] doc: LazyVim Added configuration examples for LazyVim and Treesitter. --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 05ee71fb5..58377e926 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,42 @@ local M = { return M ``` +#### LazyVim + +~/.config/nvim/lua/config/lsp.lua based on https://github.com/neovim/nvim-lspconfig/blob/master/lsp/ols.lua + +``` +return { + { + "neovim/nvim-lspconfig", + opts = { + servers = { + ols = { + cmd = { "ols" }, + filetypes = { "odin" }, + root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), + }, + }, + }, + }, +} +``` + +~/.config/nvim/lua/plugins/treesitter.lua + +```lua +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "odin", + }, + }, + }, +} +``` + ### Emacs For Emacs, there are two packages available for LSP; lsp-mode and eglot. From ccf5392b41b5abbf72eba655edfcd9f277e6e443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Thu, 16 Oct 2025 15:50:48 +0200 Subject: [PATCH 02/11] Fix LSP configuration path and setup method needed to use setup and full ols path --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 58377e926..2c6a32dd1 100644 --- a/README.md +++ b/README.md @@ -276,19 +276,20 @@ return M #### LazyVim -~/.config/nvim/lua/config/lsp.lua based on https://github.com/neovim/nvim-lspconfig/blob/master/lsp/ols.lua +~/.config/nvim/lua/plugins/lsp.lua based on https://github.com/neovim/nvim-lspconfig/blob/master/lsp/ols.lua ``` return { { "neovim/nvim-lspconfig", opts = { - servers = { - ols = { - cmd = { "ols" }, + setup = { + require('lspconfig').ols.setup { + -- needs to be full path, otherwise ols cannot find builtin folder + cmd = { vim.fn.exepath("ols") }, filetypes = { "odin" }, root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), - }, + } }, }, }, From 9ae400166ec76c3cd5ab53c9dc8094bac7d3ef8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Thu, 16 Oct 2025 15:52:15 +0200 Subject: [PATCH 03/11] LspLog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c6a32dd1..fb2c89214 100644 --- a/README.md +++ b/README.md @@ -285,7 +285,7 @@ return { opts = { setup = { require('lspconfig').ols.setup { - -- needs to be full path, otherwise ols cannot find builtin folder + -- needs to be full path, :LspLog shows that ols cannot find builtin folder. cmd = { vim.fn.exepath("ols") }, filetypes = { "odin" }, root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), From c9d3220e2b7ede7b3fd5fc8760248b033c7f705c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 02:48:56 +0200 Subject: [PATCH 04/11] conform needed --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index fb2c89214..1d5138447 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,20 @@ return { } ``` +~/.config/nvim/lua/plugins/conform.lua + +```lua +return { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + -- needed: autoformat of odin files will behave strange when used with ols + odin = { "odinfmt" }, + }, + }, +} +``` + ### Emacs For Emacs, there are two packages available for LSP; lsp-mode and eglot. From 7c40b2eab4ffb81fad91c79e8ce550d8c61348df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 05:18:16 +0200 Subject: [PATCH 05/11] Disable LSP completion for the Odin language server due to incorrect behavior --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 1d5138447..8d4922f4a 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,13 @@ return { cmd = { vim.fn.exepath("ols") }, filetypes = { "odin" }, root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), + on_attach = function(client) + -- Disable lsp completion, because it works incorrectly. + -- i.e. typing rl. will show all + -- but typing rl.Draw will not show DrawRectangleV + client.server_capabilities.completionProvider = nil + end, + } }, }, From 4be1a4aaf8508f9915c8471ff54a4a6b301b395a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 05:18:57 +0200 Subject: [PATCH 06/11] Fix code block formatting in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d4922f4a..728156ea9 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ return M ~/.config/nvim/lua/plugins/lsp.lua based on https://github.com/neovim/nvim-lspconfig/blob/master/lsp/ols.lua -``` +```lua return { { "neovim/nvim-lspconfig", From 9404362e2830dd4d57f0d38d2d0575ceac38a9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 14:04:22 +0200 Subject: [PATCH 07/11] Comment out disabling lsp completion --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 728156ea9..4fbb9ca88 100644 --- a/README.md +++ b/README.md @@ -289,13 +289,8 @@ return { cmd = { vim.fn.exepath("ols") }, filetypes = { "odin" }, root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), - on_attach = function(client) - -- Disable lsp completion, because it works incorrectly. - -- i.e. typing rl. will show all - -- but typing rl.Draw will not show DrawRectangleV - client.server_capabilities.completionProvider = nil - end, - + -- disable lsp completion if bug happens in ols + -- on_attach = function(client) client.server_capabilities.completionProvider = nil end, } }, }, From 71f54e1dd99c2ada852fd2d1dcf13bda06ad5e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 14:06:02 +0200 Subject: [PATCH 08/11] spaces --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fbb9ca88..b7956f3c9 100644 --- a/README.md +++ b/README.md @@ -289,8 +289,8 @@ return { cmd = { vim.fn.exepath("ols") }, filetypes = { "odin" }, root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), - -- disable lsp completion if bug happens in ols - -- on_attach = function(client) client.server_capabilities.completionProvider = nil end, + -- disable lsp completion if bug happens in ols + -- on_attach = function(client) client.server_capabilities.completionProvider = nil end, } }, }, From fc84f415ba7d95b99a578f0888cc2582b16f3244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 14:12:46 +0200 Subject: [PATCH 09/11] No need conform.nvim for now --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b7956f3c9..18e5512a0 100644 --- a/README.md +++ b/README.md @@ -285,7 +285,7 @@ return { opts = { setup = { require('lspconfig').ols.setup { - -- needs to be full path, :LspLog shows that ols cannot find builtin folder. + -- needs to be full path, :LspLog shows ols cannot find builtin folder otherwise. cmd = { vim.fn.exepath("ols") }, filetypes = { "odin" }, root_dir = require("lspconfig.util").root_pattern('ols.json', '.git', '*.odin'), @@ -313,6 +313,8 @@ return { } ``` +You may need conform.nvim if autoformat with sole ols of odin files is behaving strange + ~/.config/nvim/lua/plugins/conform.lua ```lua @@ -320,7 +322,6 @@ return { "stevearc/conform.nvim", opts = { formatters_by_ft = { - -- needed: autoformat of odin files will behave strange when used with ols odin = { "odinfmt" }, }, }, From f0c4b882df30f598e540889cfc14abd268767dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Fri, 17 Oct 2025 23:26:22 +0200 Subject: [PATCH 10/11] for format on save works if code in src directory --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 18e5512a0..e9a5ead88 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,8 @@ require'lspconfig'.ols.setup { } ``` +Note: Look at `:LspLog`. Now it seems your code needs to be in src directory in order for format on save to work. + Neovim can run Odinfmt on save using the [conform](https://github.com/stevearc/conform.nvim) plugin. Here is a sample configuration using the [lazy.nvim](https://github.com/folke/lazy.nvim) package manager: ```lua From bc07cd895236ffcc4de55b05d463222402a714ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Sat, 18 Oct 2025 00:34:58 +0200 Subject: [PATCH 11/11] works withou src now --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e9a5ead88..18e5512a0 100644 --- a/README.md +++ b/README.md @@ -248,8 +248,6 @@ require'lspconfig'.ols.setup { } ``` -Note: Look at `:LspLog`. Now it seems your code needs to be in src directory in order for format on save to work. - Neovim can run Odinfmt on save using the [conform](https://github.com/stevearc/conform.nvim) plugin. Here is a sample configuration using the [lazy.nvim](https://github.com/folke/lazy.nvim) package manager: ```lua