mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
enc: update default config
This commit is contained in:
parent
5df3f7b2ab
commit
dc19ff45d8
5 changed files with 144 additions and 60 deletions
|
@ -2,51 +2,63 @@
|
|||
-- cpp="gcc $fileName -lstdc++ -o $fileNameWithoutExt && $fileNameWithoutExt"
|
||||
local pyrun = "python -u"
|
||||
if vim.fn.has("win32") == 0 then
|
||||
pyrun = "python3 -u"
|
||||
pyrun = "python3 -u"
|
||||
end
|
||||
local rfile = {
|
||||
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
|
||||
python = pyrun,
|
||||
typescript = "ts-node $dir/$fileName",
|
||||
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt",
|
||||
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
|
||||
scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css",
|
||||
javascript = 'node "$dir/$fileName"',
|
||||
go = "go run .",
|
||||
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
|
||||
python = pyrun,
|
||||
typescript = "ts-node $dir/$fileName",
|
||||
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt",
|
||||
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
|
||||
scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css",
|
||||
javascript = 'node "$dir/$fileName"',
|
||||
-- go = "go run .",
|
||||
go = "go run $fileName",
|
||||
}
|
||||
|
||||
local runProject = {}
|
||||
local cwd = vim.fn.getcwd()
|
||||
local go_mod_path = cwd .. "/go.mod"
|
||||
if vim.fn.filereadable(go_mod_path) ~= 0 then
|
||||
runProject[cwd] = {
|
||||
name = "Go Project (cwd)",
|
||||
command = "go run .",
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
"CRAG666/code_runner.nvim",
|
||||
lazy = true,
|
||||
cmd = { "RunCode", "RunFile", "RunProject", "RunClose" },
|
||||
opts = {
|
||||
filetype = rfile,
|
||||
mode = "float",
|
||||
focus = true,
|
||||
startinsert = true,
|
||||
term = {
|
||||
position = "bot",
|
||||
size = 50,
|
||||
},
|
||||
float = {
|
||||
close_key = "<ESC>",
|
||||
border = "rounded",
|
||||
height = 0.8,
|
||||
width = 0.8,
|
||||
x = 0.5,
|
||||
y = 0.5,
|
||||
border_hl = "FloatBorder",
|
||||
float_hl = "Normal",
|
||||
blend = 0,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("code_runner").setup(opts)
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>r", "", desc = " Run", mode = "n" },
|
||||
{ "<leader>rr", "<cmd>RunCode<CR>", desc = "Run Code", mode = "n" },
|
||||
{ "<leader>rf", "<cmd>RunFile<CR>", desc = "Run File", mode = "n" },
|
||||
{ "<leader>rp", "<cmd>RunProject<CR>", desc = "Run Project", mode = "n" },
|
||||
},
|
||||
"CRAG666/code_runner.nvim",
|
||||
lazy = true,
|
||||
cmd = { "RunCode", "RunFile", "RunProject", "RunClose" },
|
||||
opts = {
|
||||
filetype = rfile,
|
||||
project = runProject,
|
||||
mode = "float",
|
||||
focus = true,
|
||||
startinsert = true,
|
||||
term = {
|
||||
position = "bot",
|
||||
size = 50,
|
||||
},
|
||||
float = {
|
||||
close_key = "<ESC>",
|
||||
border = "rounded",
|
||||
height = 0.8,
|
||||
width = 0.8,
|
||||
x = 0.5,
|
||||
y = 0.5,
|
||||
border_hl = "FloatBorder",
|
||||
float_hl = "Normal",
|
||||
blend = 0,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("code_runner").setup(opts)
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>r", "", desc = " Run", mode = "n" },
|
||||
{ "<leader>rr", "<cmd>RunCode<CR>", desc = "Run Code", mode = "n" },
|
||||
{ "<leader>rf", "<cmd>RunFile<CR>", desc = "Run File", mode = "n" },
|
||||
{ "<leader>rp", "<cmd>RunProject<CR>", desc = "Run Project", mode = "n" },
|
||||
},
|
||||
}
|
||||
|
|
|
@ -11,9 +11,45 @@ return {
|
|||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "gopls" })
|
||||
-- add run command for current filebuffer
|
||||
vim.api.nvim_create_user_command("RunGo", function()
|
||||
vim.cmd("term go run " .. vim.fn.expand("%"))
|
||||
vim.api.nvim_create_user_command("GoRun", function()
|
||||
local filename = vim.fn.expand("%:p") -- path lengkap file aktif
|
||||
if not filename:match("%.go$") then
|
||||
vim.notify("current file is not a go file.", vim.log.levels.WARN, { title = "GoRun" })
|
||||
return
|
||||
end
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local go_runner = Terminal:new({
|
||||
cmd = "go run " .. filename,
|
||||
direction = "float",
|
||||
close_on_exit = false,
|
||||
hidden = true,
|
||||
})
|
||||
|
||||
go_runner:toggle()
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("GoBuild", function()
|
||||
local cwd = vim.fn.getcwd()
|
||||
local go_mod_path = cwd .. "/go.mod"
|
||||
if vim.fn.filereadable(go_mod_path) == 0 then
|
||||
vim.notify("current project is not a go project.", vim.log.levels.WARN, { title = "GoBuild" })
|
||||
return
|
||||
end
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
-- create file exe jika os adalah windows
|
||||
local filename = "output"
|
||||
if vim.fn.has("win32") == 1 then
|
||||
filename = "output.exe"
|
||||
end
|
||||
local go_runner = Terminal:new({
|
||||
cmd = "go build -o " .. filename .. " && ./" .. filename,
|
||||
direction = "float",
|
||||
close_on_exit = false,
|
||||
hidden = true,
|
||||
})
|
||||
|
||||
go_runner:toggle()
|
||||
end, {})
|
||||
end,
|
||||
},
|
||||
|
|
|
@ -127,6 +127,44 @@ return {
|
|||
return opts
|
||||
end,
|
||||
config = function(_, opts)
|
||||
if pcode.nvimtree_float then
|
||||
-- set nvimtree float view (default left side)
|
||||
opts.view = {
|
||||
adaptive_size = false,
|
||||
centralize_selection = true,
|
||||
side = "left",
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
float = {
|
||||
enable = true,
|
||||
open_win_config = function()
|
||||
local screen_w = vim.opt.columns:get()
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get()
|
||||
local window_w = screen_w * 0.5
|
||||
local window_h = screen_h * 0.9
|
||||
local window_w_int = math.floor(window_w)
|
||||
local window_h_int = math.floor(window_h)
|
||||
local center_x = (screen_w - window_w) / 2
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get()
|
||||
return {
|
||||
border = "rounded",
|
||||
relative = "editor",
|
||||
row = center_y,
|
||||
col = center_x,
|
||||
width = window_w_int,
|
||||
height = window_h_int,
|
||||
}
|
||||
end,
|
||||
},
|
||||
width = function()
|
||||
return math.floor(vim.opt.columns:get() * 0.5)
|
||||
end,
|
||||
}
|
||||
end
|
||||
require("nvim-tree").setup(opts)
|
||||
local api = require("nvim-tree.api")
|
||||
api.events.subscribe(api.events.Event.FileCreated, function(file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue