Skip to content

breaking changes for nvim 0.11 #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
manager: sudo snap
packages: go
- os: ubuntu-22.04
url: https://github.com/neovim/neovim/releases/download/v0.10.4/nvim-linux-x86_64.tar.gz
url: https://github.com/neovim/neovim/releases/download/v0.11.0/nvim-linux-x86_64.tar.gz
manager: sudo snap
packages: go
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "^1.21.0" # The Go version to download (if necessary) and use.
go-version: "^1.24.0" # The Go version to download (if necessary) and use.
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v4
Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
PACKER_DIR = ~/.local/share/nvim/site/pack/vendor/start
localtestsetup:
@mkdir -p $(PACKER_DIR)
@mkdir -p ~/tmp

@test -d $(PACKER_DIR)/plenary.nvim ||\
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim $(PACKER_DIR)/plenary.nvim

@test -d $(PACKER_DIR)/nvim-lspconfig ||\
git clone --depth 1 https://github.com/neovim/nvim-lspconfig $(PACKER_DIR)/nvim-lspconfig

@test -d $(PACKER_DIR)/guihua.lua ||\
git clone --depth 1 https://github.com/ray-x/guihua.lua $(PACKER_DIR)/guihua.lua

@test -d $(PACKER_DIR)/nvim-treesitter ||\
git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter $(PACKER_DIR)/nvim-treesitter

@test -d $(PACKER_DIR)/navigator.lua || ln -s ${shell pwd} $(PACKER_DIR)


localtestts: localtestsetup
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedFile tests/treesitter_spec.lua"

test:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ "
151 changes: 16 additions & 135 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,8 @@ require'navigator'.setup({
preview_height = 0.35, -- max height of preview windows
border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"}, -- border style, can be one of 'none', 'single', 'double',
-- 'shadow', or a list of chars which defines the border
on_attach = function(client, bufnr)
-- your hook
on_attach = function(client, bufnr) -- no longer supported for nvim > 0.11 use your own LspAttach autocmd
end,
-- put a on_attach of your own here, e.g
-- function(client, bufnr)
-- -- the on_attach will be called at end of navigator on_attach
-- end,
-- The attach code will apply to all LSP clients

ts_fold = {
enable = false,
Expand Down Expand Up @@ -284,7 +278,7 @@ require'navigator'.setup({
separator = '', -- e.g. shows  3 lines 
},
},
mason = false, -- set to true if you would like use the lsp installed by williamboman/mason
mason = false, -- Deprecated, mason no longer supported as setup lsp changed in nvim 0.11
lsp = {
enable = true, -- skip lsp setup, and only use treesitter in navigator.
-- Use this if you are not using LSP servers, and only want to enable treesitter support.
Expand Down Expand Up @@ -351,42 +345,23 @@ require'navigator'.setup({
diagnostic_update_in_insert = false, -- update diagnostic message in insert mode
display_diagnostic_qf = true, -- always show quickfix if there are diagnostic errors, set to false if you want to ignore it
-- set to 'trouble' to show diagnostcs in Trouble
ts_ls = {
filetypes = {'typescript'} -- disable javascript etc,
-- set to {} to disable the lspclient for all filetypes
},
ctags ={
cmd = 'ctags',
tagfile = 'tags',
options = '-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number',
},
gopls = { -- gopls setting
on_attach = function(client, bufnr) -- on_attach for gopls
-- your special on attach here
-- e.g. disable gopls format because a known issue https://github.com/golang/go/issues/45732
print("i am a hook, I will disable document format")
client.resolved_capabilities.document_formatting = false
end,
settings = {
gopls = {gofumpt = false} -- disable gofumpt etc,
}
-- lsp setup and config no longer supported for nvim 0.11
-- refer to nvim 0.11 lsp setup doc and lspconfig for more info
ts_ls = { -- no longer supported for nvim 0.11
},
gopls = { -- no longer supported for nvim 0.11
},
-- the lsp setup can be a function, .e.g
gopls = function()
local go = pcall(require, "go")
if go then
local cfg = require("go.lsp").config()
cfg.on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false -- efm/null-ls
end
return cfg
end
gopls = function() -- no longer supported for nvim 0.11
end,

lua_ls = {
sumneko_root_path = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server",
sumneko_binary = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server/bin/macOS/lua-language-server",
},
lua_ls = { }, -- no longer supported

servers = {'cmake', 'ltex'}, -- by default empty, and it should load all LSP clients available based on filetype
-- but if you want navigator load e.g. `cmake` and `ltex` for you , you
-- can put them in the `servers` list and navigator will auto load them.
Expand Down Expand Up @@ -569,107 +544,13 @@ Terminal nerdfont and emoji capacity. I am using Kitty with nerdfont (Victor Mon

## Integrate with williamboman/mason.nvim

If you are using mason and would like to use the lsp servers installed by mason. Please set

```lua
mason = true -- mason user
```

In the config. Also please setup the lsp server from installer setup with `server:setup{opts}`

for mason
Note: mason lspconfig no longger support as of nvim 0.11 The only change you need in in LspAttach event add if you
prefer to use mason lspconfig

```lua
use("williamboman/mason.nvim")
use({
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason").setup()
require("mason-lspconfig").setup({})
end,
})

use({
"ray-x/navigator.lua",
requires = {
{ "ray-x/guihua.lua", run = "cd lua/fzy && make" },
{ "neovim/nvim-lspconfig" },
{ "nvim-treesitter/nvim-treesitter" },
},
config = function()
require("navigator").setup({
mason = true,
})
end,
})
```

Another way to setup mason is disable navigator lsp setup and using mason setup handlers, pylsp for example

```lua
use("williamboman/mason.nvim")
use({
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason").setup()
require("mason-lspconfig").setup_handlers({
["pylsp"] = function()
require("lspconfig").pylsp.setup({
on_attach = function(client, bufnr)
require("navigator.lspclient.mapping").setup({ client = client, bufnr = bufnr }) -- setup navigator keymaps here,
require("navigator.dochighlight").documentHighlight(bufnr)
require("navigator.codeAction").code_action_prompt(bufnr)
end,
})
end,
})
require("mason-lspconfig").setup({})
end,
})

use({
"navigator.lua",
requires = {
{ "ray-x/guihua.lua", run = "cd lua/fzy && make" },
{ "nvim-lspconfig" },
{ "nvim-treesitter/nvim-treesitter" },
},
config = function()
require("navigator").setup({
mason = true,
lsp = { disable_lsp = { "pylsp" } }, -- disable pylsp setup from navigator
})
end,
})
```

Alternatively, Navigator can be used to startup the server installed by mason. as it will override the navigator setup

To start LSP installed by mason, please use following setups

```lua
require'navigator'.setup({
-- mason = false -- default value is false
lsp = {
ts_ls = { cmd = {'your typescript-language-server installed by mason'} }
-- e.g. ts_ls = { cmd = {'/home/username/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/bin/typescript-language-server'} }

}
})
```

example cmd setup (mac) for pyright :

```lua
require'navigator'.setup({
-- mason = false -- default value is false

lsp = {
pyright = {
cmd = { "/Users/username/.local/share/nvim/lsp_servers/python/node_modules/.bin/pyright-langserver", "--stdio" }
}
}
}
require("navigator.lspclient.mapping").setup({ client = client, bufnr = bufnr }) -- setup navigator keymaps here,
require("navigator.dochighlight").documentHighlight(bufnr)
require("navigator.codeAction").code_action_prompt(bufnr)
```

### Integration with other lsp plugins (e.g. rust-tools, go.nvim, clangd extension)
Expand Down Expand Up @@ -697,7 +578,7 @@ use {"ray-x/navigator.lua",
}
```

- Here is an example to setup rust with rust-tools
- Here is an example to setup rust with rust-tools (nvim < 0.11)

```lua
require('rust-tools').setup({
Expand Down
15 changes: 0 additions & 15 deletions doc/navigator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,21 +331,6 @@ Nondefault configuration example:
tagfile = 'tags'
options = '-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number'
}
gopls = { -- gopls setting
on_attach = function(client, bufnr) -- on_attach for gopls
-- your special on attach here
-- e.g. disable gopls format because a known issue https://github.com/golang/go/issues/45732
print("i am a hook, I will disable document format")
client.resolved_capabilities.document_formatting = false
end,
settings = {
gopls = {gofumpt = false} -- disable gofumpt etc,
}
},
lua_ls = {
sumneko_root_path = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server",
sumneko_binary = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server/bin/macOS/lua-language-server",
},
servers = {'cmake', 'ltex'}, -- by default empty, and it should load all LSP clients avalible based on filetype
-- but if you whant navigator load e.g. `cmake` and `ltex` for you , you
-- can put them in the `servers` list and navigator will auto load them.
Expand Down
10 changes: 10 additions & 0 deletions lsp/ccls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
init_options = {
compilationDatabaseDirectory = 'build',
root_dir =
[[ util.root_pattern("compile_commands.json", "compile_flags.txt", "CMakeLists.txt", "Makefile", ".git") or util.path.dirname ]],
index = { threads = 2 },
clang = { excludeArgs = { '-frounding-math' } },
},
flags = { allow_incremental_sync = true },
}
15 changes: 15 additions & 0 deletions lsp/clangd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
cmd = {
'clangd',
'--background-index',
'--suggest-missing-includes',
'--clang-tidy',
'--header-insertion=iwyu',
'--enable-config',
'--offset-encoding=utf-16',
'--clang-tidy-checks=-*,llvm-*,clang-analyzer-*',
'--cross-file-rename',
},
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
}
44 changes: 44 additions & 0 deletions lsp/gopls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local util = require('lspconfig').util
local hasgo = pcall(require 'go')
if hasgo then
return require('go.lsp').config()
end
return {
-- capabilities = cap,
filetypes = { 'go', 'gomod', 'gohtmltmpl', 'gotexttmpl' },
message_level = vim.lsp.protocol.MessageType.Error,
cmd = {
'gopls', -- share the gopls instance if there is one already
'-remote=auto', --[[ debug options ]] --
-- "-logfile=auto",
-- "-debug=:0",
'-remote.debug=:0',
-- "-rpc.trace",
},

flags = { allow_incremental_sync = true, debounce_text_changes = 1000 },
settings = {
gopls = {
-- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
-- flags = {allow_incremental_sync = true, debounce_text_changes = 500},
-- not supported
analyses = { unusedparams = true, unreachable = false },
codelenses = {
generate = true, -- show the `go generate` lens.
gc_details = true, -- // Show a code lens toggling the display of gc's choices.
test = true,
tidy = true,
},
usePlaceholders = true,
completeUnimported = true,
staticcheck = true,
matcher = 'fuzzy',
diagnosticsDelay = '500ms',
symbolMatcher = 'fuzzy',
gofumpt = false, -- true, -- turn on for new repos, gofmpt is good but also create code turmoils
buildFlags = { '-tags', 'integration' },
-- buildFlags = {"-tags", "functional"}
semanticTokens = false,
},
},
}
8 changes: 8 additions & 0 deletions lsp/jdtls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
return {
settings = {
java = {
signatureHelp = { enabled = true },
contentProvider = { preferred = 'fernflower' },
},
},
}
Loading
Loading