feat: add unofficial nx plugin
This commit is contained in:
parent
2dd9afa5ee
commit
598bcf86f3
4 changed files with 41 additions and 118 deletions
|
@ -1,43 +1,43 @@
|
||||||
{
|
{
|
||||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
||||||
"LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" },
|
"LuaSnip": { "branch": "master", "commit": "c4b9c7c3b02826df74b93ae91009e05b758bfacf" },
|
||||||
"SchemaStore.nvim": { "branch": "main", "commit": "11d661ae5e08f19b5256661a6491a66fa26cdcfc" },
|
"SchemaStore.nvim": { "branch": "main", "commit": "91b56a811d87b9e7e0600c95f80ff2d08245bf61" },
|
||||||
"auto-session": { "branch": "main", "commit": "51196ca66b38fc1660fdf50031cb0b31a199b7c9" },
|
"auto-session": { "branch": "main", "commit": "29a8c77a0579636d5520aebd38bdbc2e6079f2f5" },
|
||||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||||
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
||||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||||
"cosmic-ui": { "branch": "main", "commit": "c0b14531999f2bfef3d927c4dcd57a1a8fed5ee9" },
|
"cosmic-ui": { "branch": "main", "commit": "c0b14531999f2bfef3d927c4dcd57a1a8fed5ee9" },
|
||||||
"friendly-snippets": { "branch": "main", "commit": "b8fae73a479ae0a1c54f5c98fa687ae8a0addc53" },
|
"friendly-snippets": { "branch": "main", "commit": "5cc1f45c6aac699ad008fb85f6ae03236062667d" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" },
|
"gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
|
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
|
||||||
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
|
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "b9084b1f42f790d6230dc66dbcb6bcc35b148552" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "fe4cce44dec93c69be17dad79b21de867dde118a" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
|
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
|
||||||
"neodev.nvim": { "branch": "main", "commit": "a69b4c417b7e5bdeee3d181b8ff8dbc5de66fc01" },
|
"neodev.nvim": { "branch": "main", "commit": "365ef03dbf5b8579e6eb205b3500fc3bee17484a" },
|
||||||
"noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" },
|
"noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" },
|
||||||
"none-ls.nvim": { "branch": "main", "commit": "912f81829e9ab4ee3d54c3ea5a304c264f0003bc" },
|
"none-ls.nvim": { "branch": "main", "commit": "34b1311bd07bd3741e60e06b34d0709d6e5a9f0f" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" },
|
"nui.nvim": { "branch": "main", "commit": "af7dfee12fbf51d12cfc6ee386fa54f7a5a573c8" },
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" },
|
"nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
|
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" },
|
||||||
"nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" },
|
"nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "021906284dcfb938bc236f8295af2650c60cb807" },
|
"nvim-lspconfig": { "branch": "master", "commit": "114bf1875c4adef7c39c86ef538246478b4af87c" },
|
||||||
"nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" },
|
"nvim-notify": { "branch": "master", "commit": "7138c86b28de61b6866c8cae60289136f0d539fa" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "e9ac136a3ab996aa8e4253253521dcf2cb66b81b" },
|
"nvim-tree.lua": { "branch": "master", "commit": "863cf832ceb0b2377c913b7696dd7d64f4978941" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "e24dab6696aa2a6682a117e241adc32c38e93d53" },
|
"nvim-treesitter": { "branch": "master", "commit": "bdaa6b817aaef459e2d1968c50ce0061e51410e8" },
|
||||||
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
|
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "a65b202cfd08e0e69e531eab737205ff5bc082a4" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" },
|
||||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1277b4a1f451b0f18c0790e1a7f12e1e5fdebfee" },
|
"nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "7fd8d7f08be824d9d362fb2d9800b84eb15786c1" },
|
"nvim-web-devicons": { "branch": "master", "commit": "7f30f2da3c3641841ceb0e2c150281f624445e8f" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
|
"nx.nvim": { "branch": "main", "commit": "f8a3a21b3d540889401a40d1f2803083794c0372" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
|
||||||
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
|
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
|
||||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
|
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "2f3857c25bbd00ed7ac593c9d4071906369e4d20" },
|
"telescope.nvim": { "branch": "master", "commit": "45d61cc8da213e4052cf698653692b6a4c961760" },
|
||||||
"todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" },
|
"todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" },
|
||||||
"tokyonight.nvim": { "branch": "main", "commit": "e3301873c1e96903daebb98cc9b5926810bf73dd" },
|
"tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" },
|
||||||
"typescript-tools.nvim": { "branch": "master", "commit": "c43d9580c3ff5999a1eabca849f807ab33787ea7" },
|
"vim-floaterm": { "branch": "master", "commit": "97c085b2f69e931ed78bb1c260512d1e0492a754" },
|
||||||
"vim-floaterm": { "branch": "master", "commit": "3f01a623376957437f9376327637491b74719e38" },
|
"vim-fugitive": { "branch": "master", "commit": "011cf4fcb93a9649ffc6dcdff56ef948f5d0f7cc" },
|
||||||
"vim-fugitive": { "branch": "master", "commit": "f116dcc8e21021e6fbfb6b0a9f8f7b9566d933f4" },
|
|
||||||
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
|
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
|
||||||
}
|
}
|
|
@ -1,95 +0,0 @@
|
||||||
-- Major props to @failen here
|
|
||||||
-- https://github.com/pmizio/typescript-tools.nvim/issues/124
|
|
||||||
vim.api.nvim_create_user_command('NxInit', function()
|
|
||||||
local now = tostring(os.time())
|
|
||||||
local fileName = string.format('%s_graph.json', now)
|
|
||||||
-- @TODO check if we should use yarn or npx
|
|
||||||
local cmd = string.format('yarn -s nx graph --file=%s', fileName)
|
|
||||||
|
|
||||||
local function handle_response(_, code)
|
|
||||||
-- read the file into memory
|
|
||||||
local projectGraphFile = io.open(fileName, 'r')
|
|
||||||
if projectGraphFile then
|
|
||||||
-- read project graph from file
|
|
||||||
local projectGraph = vim.json.decode(projectGraphFile:read('*a'))
|
|
||||||
projectGraphFile:close()
|
|
||||||
|
|
||||||
-- remove the graph file
|
|
||||||
os.remove(fileName)
|
|
||||||
|
|
||||||
-- get typescript-tools lsp client
|
|
||||||
local lspClients = vim.lsp.get_clients()
|
|
||||||
local tsclient
|
|
||||||
for _, client in ipairs(lspClients) do
|
|
||||||
if client.name == 'typescript-tools' then
|
|
||||||
tsclient = client
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not tsclient then
|
|
||||||
print('typescript-tools.nvim not active')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get workspace root
|
|
||||||
-- always first? alternatives to get absolute workspace root?
|
|
||||||
local workspacePath = tsclient.config.workspace_folders[1].name
|
|
||||||
if not workspacePath then
|
|
||||||
print('Could not figure out workspace path')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- create external files for monodon
|
|
||||||
local externalFiles = {}
|
|
||||||
for _, project in pairs(projectGraph.graph.nodes) do
|
|
||||||
local sourceRoot = project.data.sourceRoot
|
|
||||||
|
|
||||||
-- skip the root
|
|
||||||
if sourceRoot ~= '.' and sourceRoot then
|
|
||||||
-- localte the entry file. perhaps use tsconfig.[app|lib].json
|
|
||||||
local mainFile
|
|
||||||
if
|
|
||||||
project.data
|
|
||||||
and project.data.targets
|
|
||||||
and project.data.targets.build
|
|
||||||
and project.data.targets.build.options
|
|
||||||
and project.data.targets.build.options.main
|
|
||||||
then
|
|
||||||
mainFile = workspacePath .. '/' .. project.data.targets.build.options.main
|
|
||||||
else
|
|
||||||
mainFile = workspacePath .. '/' .. sourceRoot .. '/index.ts'
|
|
||||||
end
|
|
||||||
|
|
||||||
-- insert to config
|
|
||||||
table.insert(externalFiles, {
|
|
||||||
mainFile = mainFile, -- this is not always index.ts!
|
|
||||||
directory = workspacePath .. '/' .. sourceRoot,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- print(vim.inspect(externalFiles))
|
|
||||||
-- send configuration request of monodon plugin to tsserver
|
|
||||||
local constants = require('typescript-tools.protocol.constants')
|
|
||||||
local method = constants.CustomMethods.ConfigurePlugin
|
|
||||||
local args = {
|
|
||||||
pluginName = '@monodon/typescript-nx-imports-plugin',
|
|
||||||
configuration = {
|
|
||||||
externalFiles = externalFiles,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-parameter
|
|
||||||
tsclient.request(method, args, function()
|
|
||||||
print('tsserver handled configuration request', method)
|
|
||||||
end)
|
|
||||||
print('NX Plugin initialized!')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- call nx deamon with graph request, run it in the background with job
|
|
||||||
vim.fn.jobstart(cmd, {
|
|
||||||
on_exit = handle_response,
|
|
||||||
stdout_buffered = true,
|
|
||||||
stderr_buffered = true,
|
|
||||||
})
|
|
||||||
end, {})
|
|
|
@ -1,4 +1,3 @@
|
||||||
require('cosmic.lsp.diagnostics')
|
require('cosmic.lsp.diagnostics')
|
||||||
require('cosmic.lsp.commands')
|
|
||||||
|
|
||||||
-- LSP server initialization can be found in mason-lspconfig setup
|
-- LSP server initialization can be found in mason-lspconfig setup
|
||||||
|
|
19
lua/cosmic/plugins/nx/init.lua
Normal file
19
lua/cosmic/plugins/nx/init.lua
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
local user_config = require('cosmic.core.user')
|
||||||
|
local u = require('cosmic.utils')
|
||||||
|
|
||||||
|
return {
|
||||||
|
'Equilibris/nx.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
},
|
||||||
|
opts = u.merge({
|
||||||
|
-- See below for config options
|
||||||
|
nx_cmd_root = 'yarn nx',
|
||||||
|
}, user_config.plugins.nx or {}),
|
||||||
|
-- Plugin will load when you use these keys
|
||||||
|
keys = {
|
||||||
|
{ '<leader>nx', '<cmd>Telescope nx actions<CR>', desc = 'nx actions' },
|
||||||
|
},
|
||||||
|
event = 'VeryLazy',
|
||||||
|
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nx'),
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue