diff --git a/lazy-lock.json b/lazy-lock.json index 6dcb2ac..2061c5a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -18,7 +18,6 @@ "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, "markdown.nvim": { "branch": "main", "commit": "4ab835985de62b46b6785ae160f5f709b77a0f92" }, "mason.nvim": { "branch": "main", "commit": "4546dec8b56bc56bc1d81e717e4a935bc7cd6477" }, - "mini.nvim": { "branch": "main", "commit": "f20d8cd3a116ef65f022797de064a044b217ff53" }, "nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" }, "nvim-cmp": { "branch": "main", "commit": "8202df9561b90102b41dbc1ad71945534ef4ea39" }, "nvim-colorizer.lua": { "branch": "master", "commit": "760e27df4dd966607e8fb7fd8b6b93e3c7d2e193" }, @@ -28,7 +27,7 @@ "nvim-tree.lua": { "branch": "master", "commit": "78a9ca5ed6557f29cd0ce203df44213e54bfabb9" }, "nvim-treesitter": { "branch": "master", "commit": "5a8e9644c49f992f47bacd7900f4404df6fd9d38" }, "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, - "rust-tools.nvim": { "branch": "master", "commit": "bd1aa99ffb911a1cf99b3fcf3b44c0391c57e3ef" }, + "rustaceanvim": { "branch": "master", "commit": "d3a8b145f0b3db4de9a08fcbc604659f52ee4fbc" }, "telescope.nvim": { "branch": "master", "commit": "74ce793a60759e3db0d265174f137fb627430355" }, "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, "tokyonight.nvim": { "branch": "main", "commit": "e89caa3ad6d8da9d0dd981ec74a82c55adc61ffd" }, diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 4adcf29..6cfc051 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -12,6 +12,7 @@ autocmd("TextYankPost", { end, }) + -- Remove trailing whitespaces on :w autocmd({ "BufWritePre" }, { group = KrolyxonGroup, @@ -40,81 +41,87 @@ vim.cmd([[ -- Run C/C++ fil -vim.api.nvim_buf_set_keymap(0, 'n', '', ':w:!gcc -o %:t:r % && ./%:t:r', {silent = true}) -vim.api.nvim_buf_set_keymap(0, 'n', '', ':w:!g++ -o %:t:r % && ./%:t:r', {silent = true}) -vim.api.nvim_buf_set_keymap(0, 'n', '', ':w:lua require("kterm.terminal").send("cp -f " .. vim.fn.expand("%") .. " /tmp; javac -d /tmp " .. vim.fn.expand("%") .. "; java -cp /tmp " .. vim.fn.expand("%:t:r"), "float")', {silent = true}) +vim.api.nvim_buf_set_keymap(0, 'n', '', ':w:!gcc -o %:t:r % && ./%:t:r', { silent = true }) +vim.api.nvim_buf_set_keymap(0, 'n', '', ':w:!g++ -o %:t:r % && ./%:t:r', { silent = true }) +vim.api.nvim_buf_set_keymap(0, 'n', '', + ':w:lua require("kterm.terminal").send("cp -f " .. vim.fn.expand("%") .. " /tmp; javac -d /tmp " .. vim.fn.expand("%") .. "; java -cp /tmp " .. vim.fn.expand("%:t:r"), "float")', + { silent = true }) -- vim.api.nvim_buf_set_keymap(0, 'n', '', ":w:new | term . '!gcc %:p:h && ./a.out':startinsert", {silent = true}) -- local build_commands = { - c = "!g++ -std=c++17 -o %:p:r.o %", - cpp = "!g++ -std=c++17 -Wall -O2 -o %:p:r.o %", - rust = "!cargo build --release", - go = "!go build", - -- tex = "pdflatex %", - tex = "VimtexCompile", - javascript = "", + c = "!g++ -std=c++17 -o %:p:r.o %", + cpp = "!g++ -std=c++17 -Wall -O2 -o %:p:r.o %", + rust = "!cargo build --release", + go = "!go build", + -- tex = "pdflatex %", + tex = "VimtexCompile", + javascript = "", + java = "!jrun %" } local debug_build_commands = { - c = "!g++ -std=c++17 -g -o %:p:r.o %", - cpp = "!g++ -std=c++17 -g -o %:p:r.o %", - rust = "!cargo build", - go = "!go build", + c = "!g++ -std=c++17 -g -o %:p:r.o %", + cpp = "!g++ -std=c++17 -g -o %:p:r.o %", + rust = "!cargo build", + go = "!go build", } local run_commands = { - c = "%:p:r.o", - cpp = "%:p:r.o", - rust = "cargo run --release", - go = "go run .", - tex = "", - javascript = "node %", - python = "python3 %", + c = "%:p:r.o", + cpp = "%:p:r.o", + rust = "cargo run --release", + go = "go run .", + tex = "", + javascript = "node %", + python = "python3 %", } vim.api.nvim_create_user_command("Build", function() - local filetype = vim.bo.filetype + local filetype = vim.bo.filetype - for file, command in pairs(build_commands) do - if filetype == file then - vim.cmd(command) - break + for file, command in pairs(build_commands) do + if filetype == file then + vim.cmd(command) + break + end end - end end, {}) vim.api.nvim_create_user_command("DebugBuild", function() - local filetype = vim.bo.filetype + local filetype = vim.bo.filetype - for file, command in pairs(debug_build_commands) do - if filetype == file then - vim.cmd(command) - break + for file, command in pairs(debug_build_commands) do + if filetype == file then + vim.cmd(command) + break + end end - end end, {}) vim.api.nvim_create_user_command("Run", function() - local filetype = vim.bo.filetype + local filetype = vim.bo.filetype - for file, command in pairs(run_commands) do - if filetype == file then - vim.cmd("sp") -- Vertical split - -- vim.cmd("vs") -- Horizontal split - vim.cmd("term " .. command) - vim.cmd("resize 20N") -- Comment this if horizontal - local keys = vim.api.nvim_replace_termcodes("i", true, false, true) - vim.api.nvim_feedkeys(keys, "n", false) - break + for file, command in pairs(run_commands) do + if filetype == file then + vim.cmd("sp") -- Vertical split + -- vim.cmd("vs") -- Horizontal split + vim.cmd("term " .. command) + vim.cmd("resize 20N") -- Comment this if horizontal + local keys = vim.api.nvim_replace_termcodes("i", true, false, true) + vim.api.nvim_feedkeys(keys, "n", false) + break + end end - end end, {}) vim.api.nvim_create_user_command("Ha", function() - vim.cmd([[Build]]) - vim.cmd([[Run]]) + vim.cmd([[Build]]) + vim.cmd([[Run]]) end, {}) vim.api.nvim_create_user_command("Config", function() vim.cmd([[cd ~/.config/nvim]]) end, {}) + + +vim.cmd [[ autocmd BufRead,BufNewFile *.slint set filetype=slint ]] diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 683da15..81f1bb1 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,8 +1,7 @@ local M = {} M.general = { - n = { - [""] = { " noh ", "no highlight" }, + n = { [""] = { " noh ", "no highlight" }, -- switch between windows -- [""] = { "h", "window left" }, @@ -344,10 +343,7 @@ M.rust = { plugin = true, n = { ["rr"] = { " RustRun", "RustRun" }, - ["rd"] = { " RustDebuggables ", "RustDebuggables" }, - ["ra"] = { " RustHoverActions ", "RustHoverActions" }, - ["roc"] = { " RustOpenCargo ", "RustOpenCargo" }, - ["rcg"] = { " RustViewCrateGraph ", "RustViewCrateGraph" }, + ["roc"] = { " RustOpenCargo ", "RustLsp openCargo" }, }, } diff --git a/lua/plugins/configs/rust-tools.lua b/lua/plugins/configs/rust-tools.lua deleted file mode 100644 index 8c1ec4f..0000000 --- a/lua/plugins/configs/rust-tools.lua +++ /dev/null @@ -1,62 +0,0 @@ -local present, rust = pcall(require, "rust-tools") -if not present then - return -end - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) - - -local options = { - tools = { - executor = require("rust-tools/executors").termopen, - -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. - reload_workspace_from_cargo_toml = true, - inlay_hints = { - auto = true, - only_current_line = false, - show_parameter_hints = true, - }, - hover_actions = { - auto_focus = true, - border = "rounded", - }, - on_initialized = function() - -- ih.set_all() - vim.api.nvim_create_autocmd({ - "BufEnter", - "BufReadPre", - "BufReadPost", - "BufWritePost", - "CursorHold", - "InsertLeave", - "InsertEnter", - "BufAdd", - }, { - pattern = { "*.rs" }, - callback = function() - local _, _ = pcall(vim.lsp.codelens.refresh) - end, - }) - end, - }, - server = { - on_attach = require("plugins.configs.lspconfig").on_attach, - standalone = true, - }, - - settings = { - ["rust-analyzer"] = { - checkOnSave = { - -- command = "check", - lens = { - enable = true, - }, - - command = "clippy", - } - } - } -} - -rust.setup(options) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index b65128e..3ede7ee 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -145,24 +145,27 @@ local plugins = { }, { - "simrat39/rust-tools.nvim", - -- after = "nvim-lspconfig", - -- event = "BufEnter *.rs", - ft = { "rust" }, - event = { "InsertEnter", "BufReadPre", "BufAdd", "BufNew" }, - dependencies = "neovim/nvim-lspconfig", + 'mrcjkb/rustaceanvim', + version = '^5', -- Recommended + lazy = false, -- This plugin is already lazy + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + }, + }, config = function() - require("plugins.configs.rust-tools") require("core.utils").load_mappings "rust" - end, + vim.g.rustaceanvim = { + tools = { + float_win_config = { + border = 'rounded' + } + }, + + } + end }, - -- { 'mrcjkb/rustaceanvim', - -- version = '^4', -- Recommended - -- lazy = false, -- This plugin is already lazy - -- }, - - { "Saecki/crates.nvim", event = { "BufRead Cargo.toml" },