Skip to content

Commit

Permalink
fix!: add cond for some plugins, rename :Open command
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangyinzuo committed Oct 30, 2024
1 parent 6d84a61 commit c5c3eca
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 36 deletions.
9 changes: 9 additions & 0 deletions root/.config/nvim/lua/detect.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local M = {}

M.has_typst_executable = vim.fn.executable("typst") == 1
M.has_go_executable = vim.fn.executable("go") == 1
M.has_rust_executable = vim.fn.executable("rustc") == 1
M.has_coqtop_executable = vim.fn.executable("coqtop") == 1
M.has_pdflatex_executable = vim.fn.executable("pdflatex") == 1

return M
12 changes: 7 additions & 5 deletions root/.config/nvim/lua/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ local function setup_lsp(on_attach, capabilities)
})
end

-- tinymist: lsp for typst. See https://github.com/Myriad-Dreamin/tinymist
lspconfig.tinymist.setup({
-- Installed via 'chomosuke/typst-preview.nvim'
cmd = { vim.fn.stdpath("data") .. "/typst-preview/tinymist-linux-x64" },
})
if require("detect").has_typst_executable then
-- tinymist: lsp for typst. See https://github.com/Myriad-Dreamin/tinymist
lspconfig.tinymist.setup({
-- Installed via 'chomosuke/typst-preview.nvim'
cmd = { vim.fn.stdpath("data") .. "/typst-preview/tinymist-linux-x64" },
})
end

-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#jsonls
-- npm i -g vscode-langservers-extracted
Expand Down
48 changes: 29 additions & 19 deletions root/.config/nvim/lua/plugins/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local plugins_setup = require("plugins_setup")
local has_typst_executable = require("detect").has_typst_executable

return {
-- Alternatives: https://github.com/Tsuzat/NeoSolarized.nvim
Expand Down Expand Up @@ -195,19 +196,19 @@ return {
},
-- A graphical display window manager in neovim
-- {'altermo/nxwm',branch='x11'},
{
"sourcegraph/sg.nvim",
dependencies = {
"nvim-lua/plenary.nvim", --[[ "nvim-telescope/telescope.nvim ]]
},
config = function()
vim.keymap.set("n", "<leader>sg", function()
require("sg.extensions.telescope").fuzzy_search_results()
end)
end,
-- If you have a recent version of lazy.nvim, you don't need to add this!
build = "nvim -l build/init.lua",
},
-- {
-- "sourcegraph/sg.nvim",
-- dependencies = {
-- "nvim-lua/plenary.nvim", --[[ "nvim-telescope/telescope.nvim ]]
-- },
-- config = function()
-- vim.keymap.set("n", "<leader>sg", function()
-- require("sg.extensions.telescope").fuzzy_search_results()
-- end)
-- end,
-- -- If you have a recent version of lazy.nvim, you don't need to add this!
-- build = "nvim -l build/init.lua",
-- },

-- find and replace
{
Expand Down Expand Up @@ -240,17 +241,26 @@ return {
build = "cd lua/fzy && make",
},
{
'MeanderingProgrammer/render-markdown.nvim',
"MeanderingProgrammer/render-markdown.nvim",
opts = {},
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
},
{
'chomosuke/typst-preview.nvim',
ft = 'typst',
build = function() require 'typst-preview'.update() end,
}
"chomosuke/typst-preview.nvim",
cond = has_typst_executable,
ft = "typst",
build = function()
require("typst-preview").update()
end,
},
{
"jiangyinzuo/typst.vim",
cond = has_typst_executable,
ft = "typst",
branch = "patch-1",
},
-- {
-- "amitds1997/remote-nvim.nvim",
-- version = "*", -- Pin to GitHub releases
Expand Down
6 changes: 5 additions & 1 deletion root/.config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ local lualine = {
"nvim-lualine/lualine.nvim",
}

local detect = require("detect")

if vim.g.vimrc_lsp == "nvim-lsp" then
lualine.dependencies = {
"neovim/nvim-lspconfig",
Expand Down Expand Up @@ -211,14 +213,16 @@ if vim.g.vimrc_lsp == "nvim-lsp" then
},
{
"mrcjkb/rustaceanvim",
version = "^5", -- Recommended
cond = detect.has_rust_executable,
-- version = "^5", -- Recommended
lazy = false, -- This plugin is already lazy
ft = { "rust" },
},
{
-- NOTE: must ensure `go env GOPATH`/bin is in $PATH,
-- do not use apt install gopls, whose version is (unknown) and can not be parsed by go.nvim.
"ray-x/go.nvim",
cond = detect.has_go_executable,
dependencies = { -- optional packages
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
Expand Down
5 changes: 4 additions & 1 deletion root/.config/nvim/lua/plugins/nvim_cmp.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
return {
{
"micangl/cmp-vimtex",
cond = require("detect").has_pdflatex_executable,
},
{
"hrsh7th/nvim-cmp",
dependencies = {
Expand All @@ -13,7 +17,6 @@ return {
-- 请检查:verbose set omnifunc? 是否符合预期
"garymjr/nvim-snippets",
"hrsh7th/cmp-omni",
"micangl/cmp-vimtex",
},
config = require("nvim_cmp").nvim_cmp,
},
Expand Down
8 changes: 5 additions & 3 deletions root/.config/nvim/lua/plugins/vimplug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if vim.g.vimrc_lsp == "coc.nvim" then
table.insert(leaderf_dependencies, "skywind3000/Leaderf-snippet")
end

local detect = require("detect")

local M = {
-- SQLComplete: the dbext plugin must be loaded for dynamic SQL completion https://github.com/neovim/neovim/issues/14433
-- let g:omni_sql_default_compl_type = 'syntax'
Expand All @@ -21,6 +23,7 @@ local M = {
"jiangyinzuo/bd.vim",
{
"lervag/vimtex",
cond = detect.has_pdflatex_executable,
ft = "tex",
init = function()
vim.api.nvim_command("source ~/.vim/vimrc.d/latex.vim")
Expand Down Expand Up @@ -105,7 +108,6 @@ local M = {
"samoshkin/vim-mergetool",
"godlygeek/tabular",
{ "axvr/org.vim", ft = "org" },
{ "jiangyinzuo/typst.vim", ft = "typst", branch = "patch-1" },
{
"inkarkat/vim-AdvancedSorters",
dependencies = {
Expand All @@ -128,7 +130,7 @@ local M = {
"goerz/jupytext.vim",
{ "jpalardy/vim-slime", ft = { "python", "ocaml" } },
"jiangyinzuo/vim-markdown",
{ "whonore/Coqtail", ft = "coq" },
{ "whonore/Coqtail", cond = detect.has_coqtop_executable, ft = "coq" },
{
dir = "~/.vim/pack/my_plugins/start/project.vim",
dependencies = {
Expand Down Expand Up @@ -184,7 +186,7 @@ local M = {
end,
dependencies = leaderf_dependencies,
},
{ "sebdah/vim-delve", ft = "go" },
{ "sebdah/vim-delve", cond = detect.has_go_executable, ft = "go" },
}

if vim.g.vimrc_lsp == "coc.nvim" then
Expand Down
14 changes: 7 additions & 7 deletions root/.vim/vimrc.d/asynctasks.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ let g:asynctasks_term_reuse = 1
let g:asynctasks_term_rows = 4
let g:asynctasks_term_focus = 1

command! -nargs=0 Cdroot let project_root = asyncrun#current_root() | exe 'cd ' . project_root | pwd
command! -nargs=0 Lcdroot let project_root = asyncrun#current_root() | exe 'lcd ' . project_root | pwd
command! -nargs=0 Tcdroot let project_root = asyncrun#current_root() | exe 'tcd ' . project_root | pwd
command! -nargs=0 CdrootCfile let project_root = asyncrun#get_root('%:p:h') | exe 'cd ' . project_root | pwd
command! -nargs=0 LcdrootCfile let project_root = asyncrun#get_root('%:p:h') | exe 'lcd ' . project_root | pwd
command! -nargs=0 TcdrootCfile let project_root = asyncrun#get_root('%:p:h') | exe 'tcd ' . project_root | pwd
command -nargs=0 Cdroot let project_root = asyncrun#current_root() | exe 'cd ' . project_root | pwd
command -nargs=0 Lcdroot let project_root = asyncrun#current_root() | exe 'lcd ' . project_root | pwd
command -nargs=0 Tcdroot let project_root = asyncrun#current_root() | exe 'tcd ' . project_root | pwd
command -nargs=0 CdrootCfile let project_root = asyncrun#get_root('%:p:h') | exe 'cd ' . project_root | pwd
command -nargs=0 LcdrootCfile let project_root = asyncrun#get_root('%:p:h') | exe 'lcd ' . project_root | pwd
command -nargs=0 TcdrootCfile let project_root = asyncrun#get_root('%:p:h') | exe 'tcd ' . project_root | pwd

command -nargs=* -complete=customlist,asynctasks_custom#MakefileComplete Make AsyncTask make +make_target=<args>
command -bang -nargs=* -complete=file MakeInternalCmd AsyncRun -program=make @ <args>

command -nargs=? Open call asynctasks_custom#Open(<q-args>)
command -nargs=? OpenCFile call asynctasks_custom#Open(<q-args>)

0 comments on commit c5c3eca

Please sign in to comment.