-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyTest.lua
More file actions
104 lines (94 loc) · 4.23 KB
/
myTest.lua
File metadata and controls
104 lines (94 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
----------------------------------------------------------------------------
-- configurations
----------------------------------------------------------------------------
require("globals")
local nvim_config = _G.GetConfig()
local function show_current_working_dir()
-- Automatic change to working directory you start Neovim
local my_working_dir = vim.fn.getcwd()
print(string.format("current working dir = %s", my_working_dir))
vim.api.nvim_command("cd " .. my_working_dir)
end
---@diagnostic disable-next-line: unused-function, unused-local
local function nvim_env_info() -- luacheck: ignore
----------------------------------------------------------------------------
-- Neovim installed info
----------------------------------------------------------------------------
print("init.lua is loaded!")
print("Neovim RTP(Run Time Path ...)")
---@diagnostic disable-next-line: undefined-field
_G.PrintTableWithIndent(vim.opt.runtimepath:get(), 4) -- luacheck: ignore
print("====================================================================")
print(string.format("OS = %s", nvim_config["os"]))
print(string.format("Working Directory: %s", vim.fn.getcwd()))
print("Configurations path: " .. nvim_config["config"])
print("Run Time Path: " .. nvim_config["runtime"])
print(string.format("Plugins management installed path: %s", nvim_config["install_path"]))
print("path of all snippets")
_G.PrintTableWithIndent(nvim_config["snippets"], 4)
print("--------------------------------------------------------------------")
end
---@diagnostic disable-next-line: unused-function, unused-local
local function debugpy_info()
----------------------------------------------------------------------------
-- Debugpy installed info
----------------------------------------------------------------------------
local venv = nvim_config["python"]["venv"]
print(string.format("$VIRTUAL_ENV = %s", venv))
local debugpy_path = nvim_config["python"]["debugpy_path"]
if _G.IsFileExist(debugpy_path) then
print("Debugpy is installed in path: " .. debugpy_path)
else
print("Debugpy isn't installed in path: " .. debugpy_path .. "yet!")
end
print("--------------------------------------------------------------------")
end
---@diagnostic disable-next-line: unused-function, unused-local
local function nodejs_info() -- luacheck: ignore
----------------------------------------------------------------------------
-- vscode-js-debug installed info
----------------------------------------------------------------------------
print(string.format("node_path = %s", nvim_config.nodejs.node_path))
print(string.format("vim.g.node_host_prog = %s", vim.g.node_host_prog))
local js_debugger_path = nvim_config["nodejs"]["debugger_path"]
if _G.IsFileExist(js_debugger_path) then
print(string.format("nodejs.debugger_path = %s", nvim_config.nodejs.debugger_path))
else
print("JS Debugger isn't installed! " .. js_debugger_path .. "yet!")
end
print(string.format("debugger_cmd = %s", ""))
_G.PrintTableWithIndent(nvim_config.nodejs.debugger_cmd, 4)
print("====================================================================")
end
------------------------------------------------------------------------------
-- Test
------------------------------------------------------------------------------
-- Add local LuaRocks installation directory to package path
-- package.path = package.path .. ";~/.config/nvim/lua/rocks/?.lua"
-- package.path = package.path .. ";~/.config/nvim/lua/?.lua"
-- package.cpath = package.cpath .. ";~/.config/nvim/lua/rocks/?.so"
-- vim.cmd([[
-- luafile ~/.config/nvim/lua/my-chatgpt.lua
-- ]])
function _G.my_test_1()
-- Set some options
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.expandtab = true
-- Create a new buffer and set its contents
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "Hello, world!" })
-- Open the new buffer in a split window
vim.api.nvim_command("split")
vim.api.nvim_buf_set_name(buf, "hello.txt")
end
function _G.run_shell_command()
local command = "ls -l"
local output = vim.fn.system(command)
print(output)
end
-- _G.run_shell_command()
-- show_current_working_dir()
-- debugpy_info()
-- nvim_env_info()
-- nodejs_info()