Skip to content

Commit

Permalink
module split
Browse files Browse the repository at this point in the history
  • Loading branch information
mongia authored and mongia committed Apr 26, 2024
1 parent 6a08170 commit 80c47b2
Show file tree
Hide file tree
Showing 23 changed files with 548 additions and 411 deletions.
1 change: 1 addition & 0 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"nvim-dap": { "branch": "master", "commit": "56118cee6af15cb9ddba9d080880949d8eeb0c9f" },
"nvim-dap-ui": { "branch": "master", "commit": "4ce7b97dd8f50b4f672948a34bf8f3a56214fdb8" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "ab988dbb7d20cdaebf9b3ef7554a89f6895de042" },
"nvim-go": { "branch": "main", "commit": "b087899bed533b0bc53b4ac21dd0c9b9a76a931e" },
"nvim-lspconfig": { "branch": "master", "commit": "8dc45a5c142f0b5a5dd34e5cdba33217d5dc6a86" },
"nvim-navic": { "branch": "master", "commit": "15704c607569d6c5cfeab486d3ef9459645a70ce" },
"nvim-notify": { "branch": "master", "commit": "f3024b912073774111202f5fa6518b0cd2a74432" },
Expand Down
24 changes: 24 additions & 0 deletions lua/config/keymaps.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
--
local _M = {}

function _M.SymbolsOutlineKeyMaps()
return {
{ "<leader>S", "<cmd>SymbolsOutline<cr>", desc = "SymbolsOutline" },
}
end

function _M.LeetBuddyKeyMaps()
return {
{ "<leader>cQ", "<cmd>LBQuestions<cr>", desc = "leetcode List Questions" },
{ "<leader>cL", "<cmd>LBQuestion<cr>", desc = "leetcode View Question" },
{ "<leader>cR", "<cmd>LBReset<cr>", desc = "leetcode Reset Code" },
{ "<leader>cT", "<cmd>LBTest<cr>", desc = "leetcode Run Code" },
{ "<leader>cS", "<cmd>LBSubmit<cr>", desc = "leetcode Submit Code" },
}
end

function _M.BasicKeyMaps()
vim.keymap.set("n", "<S-h>", "<cmd>echo<cr>", { desc = "hello world demo" })
end

return _M
17 changes: 17 additions & 0 deletions lua/plugin_config/alpha.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local _M = {}

function _M.option()
local dashboard = require("alpha.themes.dashboard")
local logo = [[
███╗ ███╗ ██████╗ ███╗ ██╗ ██████╗ ██╗ █████╗
████╗ ████║██╔═══██╗████╗ ██║██╔════╝ ██║██╔══██╗
██╔████╔██║██║ ██║██╔██╗ ██║██║ ███╗██║███████║
██║╚██╔╝██║██║ ██║██║╚██╗██║██║ ██║██║██╔══██║
██║ ╚═╝ ██║╚██████╔╝██║ ╚████║╚██████╔╝██║██║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═╝
]]
dashboard.section.header.val = vim.split(logo, "\n")
return dashboard
end

return _M
26 changes: 26 additions & 0 deletions lua/plugin_config/dap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local c_cpp_rust_config = require("plugin_config.dap.c_cpp_rust")
local go_config = require("plugin_config.dap.go")
local node_config = require("plugin_config.dap.node")
local python_config = require("plugin_config.dap.python")

local _M = {}

function _M.config()
local Config = require("lazyvim.config")
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })

for name, sign in pairs(Config.icons.dap) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end

c_cpp_rust_config.config()
go_config.config()
node_config.config()
python_config.config()
end

return _M
50 changes: 50 additions & 0 deletions lua/plugin_config/dap/c_cpp_rust.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local _M = {}

function _M.config()
local dap = require("dap")
dap.adapters.codelldb = {
type = "server",
port = "${port}",
executable = {
-- CHANGE THIS to your path!
command = "codelldb",
args = { "--port", "${port}" },

-- On windows you may have to uncomment this:
-- detached = false,
},
}
dap.configurations.cpp = {
{
name = "Launch",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = function()
local input = vim.fn.input("Input args: ")
return vim.fn.split(input, " ", true)
end,

-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
--
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
--
-- Otherwise you might get the following error:
--
-- Error on launch: Failed to attach to the target process
--
-- But you should be aware of the implications:
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
runInTerminal = false,
},
}

dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
end

return _M
74 changes: 74 additions & 0 deletions lua/plugin_config/dap/go.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
local _M = {}

function _M.config()
local dap = require("dap")
dap.adapters.go = function(callback)
local stdout = vim.loop.new_pipe(false)
local handle
local pid_or_err
local port = 38697
local opts = {
stdio = { nil, stdout },
args = { "dap", "-l", "127.0.0.1:" .. port },
detached = true,
}
handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code)
stdout:close()
handle:close()
if code ~= 0 then
vim.notify(
string.format(
'"dlv" exited with code: %d, please check your configs for correctness.',
code
),
vim.log.levels.WARN,
{ title = "[go] DAP Warning!" }
)
end
end)
assert(handle, "Error running dlv: " .. tostring(pid_or_err))
stdout:read_start(function(err, chunk)
assert(not err, err)
if chunk then
vim.schedule(function()
require("dap.repl").append(chunk)
end)
end
end)
-- Wait for delve to start

vim.defer_fn(function()
callback({ type = "server", host = "127.0.0.1", port = port })
end, 100)
end
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
dap.configurations.go = {
{ type = "go", name = "Debug", request = "launch", program = "${file}" },
{
type = "go",
name = "Debug with args",
request = "launch",
program = "${file}",
args = function()
local argument_string = vim.fn.input("Program arg(s): ")
return vim.fn.split(argument_string, " ", true)
end,
},
{
type = "go",
name = "Debug test", -- configuration for debugging test files
request = "launch",
mode = "test",
program = "${file}",
}, -- works with go.mod packages and sub packages
{
type = "go",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}",
},
}
end

return _M
33 changes: 33 additions & 0 deletions lua/plugin_config/dap/node.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local _M = {}

function _M.config()
local dap = require("dap")
--node configurations
dap.adapters.node2 = {
type = 'executable',
command = 'node',
args = { vim.fn.stdpath("data") .. "/mason/packages/node-debug2-adapter/out/src/nodeDebug.js" },
}
dap.configurations.javascript = {
{
name = 'Launch',
type = 'node2',
request = 'launch',
program = '${file}',
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = 'inspector',
console = 'integratedTerminal',
},
{
-- For this to work you need to make sure the node process is started with the `--inspect` flag.
name = 'Attach to process',
type = 'node2',
request = 'attach',
restart = true,
processId = require 'dap.utils'.pick_process,
},
}
end

return _M
54 changes: 54 additions & 0 deletions lua/plugin_config/dap/python.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
local _M = {}

function _M.config()
local dap = require("dap")
local function isempty(s)
return s == nil or s == ""
end
dap.adapters.python = function(cb, config)
if config.request == "attach" then
---@diagnostic disable-next-line: undefined-field
local port = (config.connect or config).port or 8080
---@diagnostic disable-next-line: undefined-field
local host = (config.connect or config).host or "127.0.0.1"
cb({
type = "server",
port = assert(port, "`connect.port` is required for a python `attach` configuration"),
host = host,
options = {
source_filetype = "python",
},
})
else
cb({
type = "executable",
command = '/usr/bin/python3',
-- command = os.getenv("VIRTUAL_ENV") .. "/bin/python",
args = { "-m", "debugpy.adapter" },
options = {
source_filetype = "python",
},
})
end
end
dap.configurations.python = {
{
-- The first three options are required by nvim-dap
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
request = "launch",
name = "Launch file",
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options

program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
if not isempty(vim.env.CONDA_PREFIX) then
return vim.env.CONDA_PREFIX .. "/bin/python"
else
return "/usr/bin/python3"
end
end,
},
}
end

return _M
88 changes: 88 additions & 0 deletions lua/plugin_config/gutentags.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
local _M = {}

function _M.config()
vim.g.gutentags_ctags_exclude = {
'*.git',
'*.svg',
'*.hg',
'*/tests/*',
'build',
'dist',
'*sites/*/files/*',
'bin',
'node_modules',
'bower_components',
'cache',
'compiled',
'docs',
'example',
'bundle',
'vendor',
'*.md',
'*-lock.json',
'*.lock',
'*bundle*.js',
'*build*.js',
'.*rc*',
'*.json',
'*.min.*',
'*.map',
'*.bak',
'*.zip',
'*.pyc',
'*.class',
'*.sln',
'*.Master',
'*.csproj',
'*.tmp',
'*.csproj.user',
'*.cache',
'*.pdb',
'tags*',
'cscope.*',
-- '*.css',
-- '*.less',
-- '*.scss',
'*.exe',
'*.dll',
'*.mp3',
'.md',
'*.ogg',
'*.flac',
'*.swp',
'*.swo',
'*.bmp',
'*.gif',
'*.ico',
'*.jpg',
'*.png',
'*.rar',
'*.zip',
'*.tar',
'*.tar.gz',
'*.tar.xz',
'*.tar.bz2',
'*.pdf',
'*.doc',
'*.docx',
'*.ppt',
'*.pptx',
}

vim.g.gutentags_add_default_project_roots = false
vim.g.gutentags_project_root = { 'package.json', '.git', '.svn', '.root', '.hg', '.vscode', '.project' }
vim.g.gutentags_ctags_tagfile = '.tags'

vim.g.gutentags_cache_dir = vim.fn.stdpath("cache") .. '/ctags'
vim.g.gutentags_ctags_extra_args = { '--tag-relative=yes', '--fields=+ailmnS', '--extra=+q',
'--c++-kinds=+px', '--c-kinds=+px' }

-- custom
vim.g.gutentags_modules = { 'ctags' }

if vim.fn.isdirectory(vim.g.gutentags_cache_dir) == 0 then
os.execute("mkdir -p " .. vim.g.gutentags_cache_dir)
end
end

return _M
7 changes: 7 additions & 0 deletions lua/plugin_config/lazyvim.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local _M = {}

function _M.option()
return {
colorscheme = "catppuccin"
}
end
Loading

0 comments on commit 80c47b2

Please sign in to comment.