forked from roan-paulus/nvimconfig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
124 lines (104 loc) · 3.28 KB
/
init.lua
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
vim.g.python3_host_prog = "/usr/bin/python3.12"
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- [[ Settings/options ]]
vim.g.have_nerd_font = true
-- Spaces/Tabs
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.softtabstop = 0
vim.opt.autoindent = true
vim.opt.smarttab = true
-- Gutter
vim.opt.number = true
vim.opt.relativenumber = true
-- Other
vim.opt.mouse = "a"
vim.opt.breakindent = true
vim.opt.undofile = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 250
vim.opt.splitright = true
vim.opt.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor.
vim.opt.list = true
vim.opt.listchars = {
tab = " " --[[alternative value: "» "]],
trail = "·",
nbsp = "␣",
}
-- Preview substitutions live, as you type! (hightlight -> :s)
vim.opt.inccommand = "split"
vim.opt.cursorline = true
vim.opt.scrolloff = 10
vim.opt.hlsearch = true
-- [[ Keymaps ]]
-- Diagnostic
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous [D]iagnostic message" })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next [D]iagnostic message" })
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" })
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
-- Rust
vim.api.nvim_create_autocmd("FileType", {
pattern = "rust",
callback = function(_)
vim.keymap.set("n", "<F6>", ":split term://cargo run<CR>", { desc = "Compile and run rust project" })
end,
})
-- Lua
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function(_)
vim.keymap.set("n", "<F5>", ":split term://love .<CR>", { desc = "Run love 2d game" })
end,
})
-- Other
-- Make sure autocommand will fire when using ctrl-c to go to normal mode
vim.keymap.set("i", "<C-c>", "<Esc>")
vim.api.nvim_create_autocmd("TermOpen", {
callback = function(_)
vim.opt_local.number = false
vim.opt_local.relativenumber = false
vim.cmd("normal i")
end,
})
function open_vscode()
local pos = vim.fn.getpos(".")
local file = vim.api.nvim_buf_get_name(pos[1])
local lnum = pos[2]
local col = pos[3]
vim.cmd(string.format("!code --goto %s:%s:%s", file, lnum, col))
end
vim.keymap.set("n", "<leader>vs", open_vscode, { desc = "Open vscode on current line and character" })
-- [[ Install `lazy.nvim` plugin manager ]]
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
-- [[ Configure and install plugins ]]
-- "plugins" after .setup causes layze to load lua/plugins.lua and lua/plugins/*.lua
require("lazy").setup("plugins", {
ui = {
icons = vim.g.have_nerd_font and {} or {
cmd = "⌘",
config = "🛠",
event = "📅",
ft = "📂",
init = "⚙",
keys = "🗝",
plugin = "🔌",
runtime = "💻",
require = "🌙",
source = "📄",
start = "🚀",
task = "📌",
lazy = "💤 ",
},
},
})