[breaking] Neodev (#237)

[BREAKING] deprecate lua-dev setup and in favor neodev 
* lua-dev -> neodev
* update deprecated messages
pull/240/head
rayx 2 years ago committed by GitHub
parent 4353d64fa3
commit 7a88235bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -699,15 +699,16 @@ Here is an example [init_lsp_installer.lua](https://github.com/ray-x/navigator.l
There are lots of plugins provides lsp support There are lots of plugins provides lsp support
* go.nvim allow you either hook gopls from go.nvim or from navigator and it can export the lsp setup from go.nvim. * go.nvim allow you either hook gopls from go.nvim or from navigator and it can export the lsp setup from go.nvim.
* rust-tools and clangd allow you to setup on_attach from config server * rust-tools and clangd allow you to setup on_attach from config server
* [lua-dev](https://github.com/folke/lua-dev.nvim) Dev setup for init.lua and plugin development. Navigator can * [neodev](https://github.com/folke/neodev.nvim) Dev setup for lua development. Navigator help you setup neodev
extend lua setup with lua-dev.
Here is an example to setup rust with rust-tools Here is an example to setup rust with rust-tools
```lua ```lua
require'navigator'.setup({ require'navigator'.setup({
lsp = { lsp = {
disable_lsp = { "rust_analyzer", "clangd" }, -- will not run rust_analyzer setup from navigator disable_lsp = { "rust_analyzer", "clangd" }, -- will not run rust_analyzer setup from navigator
['lua-dev'] = { runtime_path=true } -- any non default lua-dev setups ['neodev'] = { runtime_path=true } -- any non default neodev setups, if not empty, navigator will call neodev.setup
-- with those configures
}, },
}) })

@ -66,10 +66,10 @@ _NgConfigValues = {
severity_sort = { reverse = true }, severity_sort = { reverse = true },
}, },
format_on_save = true, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc) format_on_save = true, -- {true|false} set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
-- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language -- table: {enable = {'lua', 'go'}, disable = {'javascript', 'typescript'}} to enable/disable specific language
-- enable: a whitelist of language that will be formatted on save -- enable: a whitelist of language that will be formatted on save
-- disable: a blacklist of language that will not be formatted on save -- disable: a blacklist of language that will not be formatted on save
-- function: function(bufnr) return true end to enable/disable lsp format on save -- function: function(bufnr) return true end to enable/disable lsp format on save
format_options = { async = false }, -- async: disable by default, I saw something unexpected format_options = { async = false }, -- async: disable by default, I saw something unexpected
disable_nulls_codeaction_sign = true, -- do not show nulls codeactions (as it will alway has a valid action) disable_nulls_codeaction_sign = true, -- do not show nulls codeactions (as it will alway has a valid action)
disable_format_cap = {}, -- a list of lsp disable file format (e.g. if you using efm or vim-codeformat etc), empty by default disable_format_cap = {}, -- a list of lsp disable file format (e.g. if you using efm or vim-codeformat etc), empty by default
@ -85,9 +85,9 @@ _NgConfigValues = {
-- filetypes = {'typescript'} -- disable javascript etc, -- filetypes = {'typescript'} -- disable javascript etc,
-- set to {} to disable the lspclient for all filetype -- set to {} to disable the lspclient for all filetype
}, },
['lua-dev'] = { -- navigator can use lua-dev settings to setup sumneko_lua ['neodev'] = { -- navigator can use neodev settings to setup sumneko_lua
-- your setting for lua-dev here -- your setting for neodev here
-- navigator will setup lua-dev -- navigator will setup neodev
}, },
sumneko_lua = { sumneko_lua = {
-- sumneko_root_path = sumneko_root_path, -- sumneko_root_path = sumneko_root_path,
@ -98,7 +98,7 @@ _NgConfigValues = {
}, },
lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer
mason = false, -- set to true if you would like use the lsp installed by williamboman/mason mason = false, -- set to true if you would like use the lsp installed by williamboman/mason
mason_disabled_for = {}, -- disable mason for specified lspclients mason_disabled_for = {}, -- disable mason for specified lspclients
icons = { icons = {
icons = true, -- set to false to use system default ( if you using a terminal does not have nerd/icon) icons = true, -- set to false to use system default ( if you using a terminal does not have nerd/icon)
-- Code action -- Code action

@ -50,30 +50,12 @@ local on_attach = require('navigator.lspclient.attach').on_attach
-- gopls["ui.completion.usePlaceholders"] = true -- gopls["ui.completion.usePlaceholders"] = true
-- lua setup -- lua setup
local library = {}
local luadevcfg = {
library = {
vimruntime = true, -- runtime path
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
plugins = { 'nvim-treesitter', 'plenary.nvim' },
},
lspconfig = {
-- cmd = {sumneko_binary},
on_attach = on_attach,
},
}
local luadev = {} if _NgConfigValues.lsp['lua-dev'] ~= nil then
local user_luadev = _NgConfigValues.lsp['lua-dev'] vim.notify('lua-dev is deprecated, please use neodev instead', vim.lsp.log_levels.WARN)
if user_luadev then
luadev = vim.tbl_deep_extend('force', luadev, user_luadev)
end
require('navigator.lazyloader').load('lua-dev.nvim', 'folke/lua-dev.nvim')
if _NgConfigValues.lsp_installer then
require('navigator.lazyloader').load('nvim-lsp-installer', 'williamboman/nvim-lsp-installer')
end end
require('navigator.lazyloader').load('neodev.nvim', 'folke/neodev.nvim')
if _NgConfigValues.mason then if _NgConfigValues.mason then
require('navigator.lazyloader').load('mason.nvim', 'williamboman/mason.nvim') require('navigator.lazyloader').load('mason.nvim', 'williamboman/mason.nvim')

@ -1,6 +1,8 @@
local vfn = vim.fn local vfn = vim.fn
local library = {} local library = {}
local on_attach = require('navigator.lspclient.attach').on_attach
local sumneko_cfg = { local sumneko_cfg = {
cmd = { 'lua-language-server' }, cmd = { 'lua-language-server' },
filetypes = { 'lua' }, filetypes = { 'lua' },
@ -57,32 +59,27 @@ local function sumneko_lua()
library[vfn.expand('$VIMRUNTIME/lua/vim')] = true library[vfn.expand('$VIMRUNTIME/lua/vim')] = true
library[vfn.expand('$VIMRUNTIME/lua/vim/lsp')] = true library[vfn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
local on_attach = require('navigator.lspclient.attach').on_attach
local luadevcfg = { local luadevcfg = {
library = { library = {
vimruntime = true, -- runtime path enabled = true, -- runtime path
runtime = true,
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
plugins = { 'nvim-treesitter', 'plenary.nvim' }, plugins = { 'nvim-treesitter', 'plenary.nvim' },
}, },
lspconfig = { setup_jsonls = true,
-- cmd = {sumneko_binary},
on_attach = on_attach,
},
} }
local luadev = {} local user_luadev = _NgConfigValues.lsp['neodev']
local user_luadev = _NgConfigValues.lsp['lua-dev']
if user_luadev then if user_luadev then
luadevcfg = vim.tbl_deep_extend('force', luadevcfg, user_luadev) luadevcfg = vim.tbl_deep_extend('force', luadevcfg, user_luadev)
end end
require('navigator.lazyloader').load('lua-dev.nvim', 'folke/lua-dev.nvim') require('navigator.lazyloader').load('neodev.nvim', 'folke/neodev.nvim')
local ok, l = pcall(require, 'lua-dev') local ok, l = pcall(require, 'neodev')
if ok and l then if ok and l then
luadev = l.setup(luadevcfg) l.setup(luadevcfg)
end end
sumneko_cfg = vim.tbl_deep_extend('force', sumneko_cfg, luadev)
return sumneko_cfg return sumneko_cfg
end end

@ -119,7 +119,7 @@ function M.prepare_for_render(items, opts)
lspapi_display = lspapi lspapi_display = lspapi
item = clone(items[i]) item = clone(items[i])
space, trim = get_pads(opts.width, icon .. ' ' .. item.display_filename, lspapi_display .. ' 12 of 33') space, trim = get_pads(opts.width, icon .. ' ' .. item.display_filename, lspapi_display .. ' 12 of 34')
if trim and opts.width > 52 and #item.display_filename > opts.width - 20 then if trim and opts.width > 52 and #item.display_filename > opts.width - 20 then
item.display_filename = string.sub(item.display_filename, 1, opts.width - 52) item.display_filename = string.sub(item.display_filename, 1, opts.width - 52)
.. '' .. ''
@ -135,7 +135,11 @@ function M.prepare_for_render(items, opts)
end end
-- content of code lines -- content of code lines
item = clone(items[i]) item = clone(items[i])
item.text = require('navigator.util').trim_and_pad(item.text) if opts.side_panel then
item.text = item.text:gsub('%s+', ' ')
else
item.text = require('navigator.util').trim_and_pad(item.text)
end
item.text = string.format('%4i: %s', item.lnum, item.text) item.text = string.format('%4i: %s', item.lnum, item.text)
local ts_report = '' local ts_report = ''
if item.lhs then if item.lhs then
@ -146,7 +150,11 @@ function M.prepare_for_render(items, opts)
-- log(item.text) -- log(item.text)
if item.definition then if item.definition then
log('definition', item) log('definition', item)
ts_report = ts_report .. _NgConfigValues.icons.value_definition .. ' ' if opts.side_panel then
ts_report = _NgConfigValues.icons.value_definition
else
ts_report = ts_report .. _NgConfigValues.icons.value_definition .. ' '
end
end end
local header_len = #ts_report + 4 -- magic number 2 local header_len = #ts_report + 4 -- magic number 2
trace(ts_report, header_len) trace(ts_report, header_len)

Loading…
Cancel
Save