Skip to content

Commit aedd32b

Browse files
committed
Add overseer/cmake-tools + neorg + configure remote-nvim
remote-nvim: - TMUX integration - Copy local plugins, needs amitds1997/remote-nvim.nvim#190
1 parent 3ae5db3 commit aedd32b

File tree

7 files changed

+205
-50
lines changed

7 files changed

+205
-50
lines changed

init.lua

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ I hope you enjoy your Neovim journey,
8585
8686
P.S. You can delete this when you're done too. It's your config now! :)
8787
--]]
88-
88+
require 'globals'
89+
--
8990
-- Set <space> as the leader key
9091
-- See `:help mapleader`
9192
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
@@ -253,7 +254,28 @@ vim.opt.rtp:prepend(lazypath)
253254
-- :Lazy update
254255
--
255256
-- NOTE: Here is where you install your plugins.
256-
require('lazy').setup {
257+
258+
-- NOTE: lazy.nvim options
259+
local lazy_config = {
260+
dev = {
261+
-- Directory where you store your local plugin projects. If a function is used,
262+
-- the plugin directory (e.g. `~/projects/plugin-name`) must be returned.
263+
path = function(plugin)
264+
if vim.g.remote_neovim_host then
265+
local remote_path = vim.fn.stdpath('config') .. '/../local_plugins/nvim/' .. plugin.name
266+
return remote_path
267+
else
268+
local local_path = "~/devel/nvim/" .. plugin.name
269+
return local_path
270+
end
271+
end,
272+
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
273+
patterns = {}, -- For example {"folke"}
274+
fallback = false, -- Fallback to git when local plugin doesn't exist
275+
},
276+
}
277+
require('lazy').setup ({
278+
257279
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
258280
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
259281

@@ -498,7 +520,7 @@ require('lazy').setup {
498520
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
499521
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
500522
{ import = 'custom.plugins' },
501-
}
523+
}, lazy_config)
502524

503525
-- The line beneath this is called `modeline`. See `:help modeline`
504526
-- vim: ts=2 sts=2 sw=2 et

lua/custom/plugins/cmake-tools.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
return {
2+
'Civitasv/cmake-tools.nvim',
3+
dependencies = { 'stevearc/overseer.nvim' },
4+
config = function()
5+
local osys = require("cmake-tools.osys")
6+
require("cmake-tools").setup {
7+
cmake_command = "cmake", -- this is used to specify cmake command path
8+
ctest_command = "ctest", -- this is used to specify ctest command path
9+
cmake_use_preset = true,
10+
cmake_regenerate_on_save = true, -- auto generate when save CMakeLists.txt
11+
cmake_generate_options = { "-DCMAKE_EXPORT_COMPILE_COMMANDS=1", "-GNinja" }, -- this will be passed when invoke `CMakeGenerate`
12+
cmake_build_options = {}, -- this will be passed when invoke `CMakeBuild`
13+
-- support macro expansion:
14+
-- ${kit}
15+
-- ${kitGenerator}
16+
-- ${variant:xx}
17+
cmake_build_directory = function()
18+
require'plenary'.log.debug("cmake_build_directory windows: " .. tostring(osys.iswin32))
19+
-- if osys.iswin32 then
20+
-- print('windows')
21+
-- return "out\\${variant:buildType}"
22+
-- end
23+
return "build/${variant:buildType}"
24+
end, -- this is used to specify generate directory for cmake, allows macro expansion, can be a string or a function returning the string, relative to cwd.
25+
cmake_soft_link_compile_commands = true, -- this will automatically make a soft link from compile commands file to project root dir
26+
cmake_compile_commands_from_lsp = false, -- this will automatically set compile commands file location using lsp, to use it, please set `cmake_soft_link_compile_commands` to false
27+
cmake_kits_path = nil, -- this is used to specify global cmake kits path, see CMakeKits for detailed usage
28+
cmake_variants_message = {
29+
short = { show = true }, -- whether to show short message
30+
long = { show = true, max_length = 40 }, -- whether to show long message
31+
},
32+
cmake_executor = { -- executor to use
33+
name = "overseer", -- name of the executor
34+
opts = {}, -- the options the executor will get, possible values depend on the executor type. See `default_opts` for possible values.
35+
},
36+
cmake_runner = { -- runner to use
37+
name = "overseer",
38+
opts = {},
39+
},
40+
}
41+
end
42+
}

lua/custom/plugins/mini.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ return { -- Collection of various small independent plugins/modules
3434

3535
-- check if this is an nvim-remote instance
3636
if vim.g.remote_neovim_host then
37-
local remote_name = (" | Remote: %s"):format(vim.uv.os_gethostname()) or ""
37+
local remote_name = (" | Remote: %s"):format(vim.g.remote_neovim_unique_host_id) or ""
3838
value = value .. remote_name
3939
end
4040

lua/custom/plugins/neorg.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
return {
2+
"nvim-neorg/neorg",
3+
lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
4+
version = "*", -- Pin Neorg to the latest stable release
5+
config = function()
6+
require("neorg").setup({
7+
load = {
8+
["core.defaults"] = {}, -- Loads default behaviour
9+
["core.concealer"] = {}, -- Adds pretty icons to your documents
10+
["core.ui.calendar"] = {},
11+
["core.completion"] = { config = { engine = "nvim-cmp", name = "[Norg]" } },
12+
["core.integrations.nvim-cmp"] = {},
13+
-- ["core.concealer"] = { config = { icon_preset = "diamond" } },
14+
["core.esupports.metagen"] = { config = { type = "auto", update_date = true } },
15+
["core.qol.toc"] = {},
16+
["core.qol.todo_items"] = {},
17+
["core.looking-glass"] = {},
18+
["core.presenter"] = { config = { zen_mode = "zen-mode" } },
19+
["core.export"] = {},
20+
["core.export.markdown"] = { config = { extensions = "all" } },
21+
["core.summary"] = {},
22+
["core.tangle"] = { config = { report_on_empty = false } },
23+
["core.dirman"] = { -- Manages Neorg workspaces
24+
config = {
25+
workspaces = {
26+
notes = "~/notes/notes",
27+
work = "~/notes/work",
28+
},
29+
default_workspace = "notes",
30+
},
31+
},
32+
},
33+
})
34+
end,
35+
}

lua/custom/plugins/overseer.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
return {
2+
'stevearc/overseer.nvim',
3+
opts = {},
4+
}

lua/custom/plugins/remote-nvim.lua

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,77 @@
11
return {
2-
"amitds1997/remote-nvim.nvim",
3-
version = "*", -- Pin to GitHub releases
4-
dependencies = {
5-
"nvim-lua/plenary.nvim", -- For standard functions
6-
"MunifTanjim/nui.nvim", -- To build the plugin UI
7-
"nvim-telescope/telescope.nvim", -- For picking b/w different remote methods
8-
},
2+
-- "amitds1997/remote-nvim.nvim",
3+
"remote-nvim.nvim",
4+
dev = true,
5+
version = "*", -- Pin to GitHub releases
6+
dependencies = {
7+
"nvim-lua/plenary.nvim", -- For standard functions
8+
"MunifTanjim/nui.nvim", -- To build the plugin UI
9+
"nvim-telescope/telescope.nvim", -- For picking b/w different remote methods
10+
},
911
config = function()
1012
require("remote-nvim").setup(
1113
{
12-
client_callback = function(port, workspace_config)
13-
local cmd = ("wezterm cli set-tab-title --pane-id $(wezterm cli spawn nvim --server localhost:%s --remote-ui) %s"):format(
14-
port,
15-
("'Remote: %s'"):format(workspace_config.host)
16-
)
17-
if vim.env.TERM == "xterm-kitty" then
18-
cmd = ("kitty -e nvim --server localhost:%s --remote-ui"):format(port)
19-
end
20-
vim.fn.jobstart(cmd, {
21-
detach = true,
22-
on_exit = function(job_id, exit_code, event_type)
23-
-- This function will be called when the job exits
24-
print("Client", job_id, "exited with code", exit_code, "Event type:", event_type)
25-
end,
26-
})
27-
end,
28-
29-
-- Remote configuration
30-
remote = {
31-
-- List of directories that should be copied over
32-
copy_dirs = {
33-
-- What to copy to remote's Neovim data directory
34-
data = {
35-
base = vim.fn.stdpath("data"),
36-
dirs = "*",
37-
compression = {
38-
enabled = true,
39-
},
40-
},
41-
-- What to copy to remote's Neovim cache directory
42-
cache = {
43-
base = vim.fn.stdpath("cache"),
44-
dirs = {'codeium'},
45-
compression = {
46-
enabled = true,
47-
},
48-
},
49-
},
50-
},
14+
-- You can supply your own callback that should be called to create the local client. This is the default implementation.
15+
-- Two arguments are passed to the callback:
16+
-- port: Local port at which the remote server is available
17+
-- workspace_config: Workspace configuration for the host. For all the properties available, see https://github.com/amitds1997/remote-nvim.nvim/blob/main/lua/remote-nvim/providers/provider.lua#L4
18+
-- A sample implementation using WezTerm tab is at: https://github.com/amitds1997/remote-nvim.nvim/wiki/Configuration-recipes
19+
client_callback = function(port, workspace_config)
20+
local cmd = ""
21+
if vim.env.TERM == "tmux-256color" then
22+
cmd = ("tmux new-window -n '%s' nvim --server localhost:%s --remote-ui"):format(
23+
workspace_config.host,
24+
port
25+
)
26+
elseif vim.env.TERM == 'wezterm' then
27+
cmd = ("wezterm cli set-tab-title --pane-id $(wezterm cli spawn nvim --server localhost:%s --remote-ui) %s"):format(
28+
port,
29+
("'Remote: %s'"):format(workspace_config.host)
30+
)
31+
elseif vim.env.TERM == "xterm-kitty" then
32+
cmd = ("kitty -e nvim --server localhost:%s --remote-ui"):format(port)
33+
end
34+
vim.fn.jobstart(cmd, {
35+
detach = true,
36+
on_exit = function(job_id, exit_code, event_type)
37+
-- This function will be called when the job exits
38+
print("Client", job_id, "exited with code", exit_code, "Event type:", event_type)
39+
end,
40+
})
41+
end,
5142

43+
-- Remote configuration
44+
remote = {
45+
-- List of directories that should be copied over
46+
copy_dirs = {
47+
local_plugins = {
48+
-- home folder
49+
base = "/home/arnaud/devel/nvim",
50+
dirs = "*",
51+
compression = {
52+
enabled = true,
53+
},
54+
},
5255

56+
-- What to copy to remote's Neovim data directory
57+
data = {
58+
base = vim.fn.stdpath("data"),
59+
-- dirs = "*",
60+
dirs = nil,
61+
compression = {
62+
enabled = true,
63+
},
64+
},
65+
-- What to copy to remote's Neovim cache directory
66+
cache = {
67+
base = vim.fn.stdpath("cache"),
68+
dirs = {'codeium'},
69+
compression = {
70+
enabled = true,
71+
},
72+
},
73+
},
74+
}
5375
}
5476
)
5577
end,

lua/globals.lua

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- load .nvim.lua per-project after init.lua
2+
-- see :help exrc
3+
vim.opt.exrc = true
4+
5+
-- Hide neovim's command line by default
6+
vim.o.cmdheight = 0
7+
8+
-- Use ESC to exit the terminal prompt
9+
vim.cmd [[
10+
au TermOpen * tnoremap <Esc><Esc> <c-\><c-n>
11+
au FileType fzf tunmap <Esc><Esc>
12+
]]
13+
14+
P = function(v)
15+
vim.print(v)
16+
return v
17+
end
18+
19+
RELOAD=function(...)
20+
return require("plenary.reload").reload_module(...)
21+
end
22+
23+
R = function(name)
24+
RELOAD(name)
25+
return require(name)
26+
end
27+
28+
-- Should only exist on lua files
29+
vim.keymap.set('n', '<leader><leader>x', ':write<CR>:source<CR>', { desc = 'Save and source current file' })
30+
vim.keymap.set('n', '<leader>t', '<Plug>PlanaryTestFile', { desc = 'Run test file using plenary' })

0 commit comments

Comments
 (0)