Initial Commit
This commit is contained in:
commit
18da9560c6
31 changed files with 769 additions and 0 deletions
9
lua/config/keymaps.lua
Normal file
9
lua/config/keymaps.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
vim.keymap.set("n", "-", "<CMD>Oil --float<CR>", { desc = "Open parent directory" })
|
||||
vim.keymap.set("n", "gl", function()
|
||||
vim.diagnostic.open_float()
|
||||
end, { desc = "Open Diagnostics in Float" })
|
||||
|
||||
vim.keymap.set("n", "<M-BS>", "<CMD>e#<CR>", { desc = "Previous file" })
|
||||
|
||||
require("config.maps.maven")
|
||||
require("config.maps.cpp")
|
||||
39
lua/config/lazy.lua
Normal file
39
lua/config/lazy.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||
-- loading lazy.nvim so that mappings are correct.
|
||||
-- This is also a good place to setup other settings (vim.opt)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
require("config.options")
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "kanagawa_wave" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true, notify = false },
|
||||
})
|
||||
|
||||
require("config.keymaps")
|
||||
37
lua/config/maps/cpp.lua
Normal file
37
lua/config/maps/cpp.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
local function is_cpp_project()
|
||||
local uv = vim.loop
|
||||
local dir = uv.fs_realpath(vim.fn.expand("%:p:h"))
|
||||
while dir do
|
||||
if uv.fs_stat(dir .. "/vcpkg.json") then
|
||||
return true
|
||||
end
|
||||
local parent_dir = uv.fs_realpath(dir .. "/..")
|
||||
if parent_dir == dir then
|
||||
break
|
||||
end
|
||||
dir = parent_dir
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Create autocommand on FileType java or whatever filetype you want
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "cppm", "h", "cpp", "CMakeLists.txt" },
|
||||
callback = function()
|
||||
if is_cpp_project() then
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader><F5>",
|
||||
"<CMD>! mkdir -p build && cd build && CC=/usr/bin/clang && CXX=/usr/bin/clang++ && cmake .. -G Ninja && cmake --build . --target copy-compile-commands && cd ..<CR>",
|
||||
{ desc = "CMake Create" }
|
||||
)
|
||||
vim.keymap.set("n", "<leader><F6>", "<CMD>! cd build && cmake --build .<CR>", { desc = "Build Project" })
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader><F8>",
|
||||
"<CMD>! cd build && cmake --build . --target run<CR>",
|
||||
{ desc = "Run Project" }
|
||||
)
|
||||
end
|
||||
end,
|
||||
})
|
||||
27
lua/config/maps/maven.lua
Normal file
27
lua/config/maps/maven.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- Function to check if pom.xml exists in current or parent directories
|
||||
local function is_maven_project()
|
||||
local uv = vim.loop
|
||||
local dir = uv.fs_realpath(vim.fn.expand("%:p:h"))
|
||||
while dir do
|
||||
if uv.fs_stat(dir .. "/pom.xml") then
|
||||
return true
|
||||
end
|
||||
local parent_dir = uv.fs_realpath(dir .. "/..")
|
||||
if parent_dir == dir then
|
||||
break
|
||||
end
|
||||
dir = parent_dir
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Create autocommand on FileType java or whatever filetype you want
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "java",
|
||||
callback = function()
|
||||
if is_maven_project() then
|
||||
vim.keymap.set("n", "<leader><F5>", "<CMD>! mvn clean install -DskipTests<CR>", { desc = "Build Java" })
|
||||
vim.keymap.set("n", "<leader><F7>", "<CMD>! mvn spotless:apply<CR>", { desc = "Format Java" })
|
||||
end
|
||||
end,
|
||||
})
|
||||
42
lua/config/options.lua
Normal file
42
lua/config/options.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
vim.g.have_nerd_font = true
|
||||
|
||||
vim.opt.langmap = "+]ü["
|
||||
vim.keymap.set("n", "ü", "[", { remap = true })
|
||||
|
||||
vim.opt.expandtab = true -- Convert tabs to spaces
|
||||
vim.opt.shiftwidth = 4 -- Amount to indent with << and >>
|
||||
vim.opt.tabstop = 4 -- How many spaces are shown per Tab
|
||||
vim.opt.softtabstop = 4 -- How many spaces are applied when pressing Tab
|
||||
|
||||
vim.opt.smarttab = true
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.autoindent = true -- Keep identation from previous line
|
||||
|
||||
vim.opt.breakindent = true
|
||||
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.cursorline = true
|
||||
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.mouse = "a"
|
||||
|
||||
vim.opt.showmode = false
|
||||
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
vim.opt.signcolumn = "yes"
|
||||
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||
|
||||
vim.opt.scrolloff = 5
|
||||
|
||||
vim.opt.cmdheight = 0
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
Loading…
Add table
Add a link
Reference in a new issue