forked from AstroNvim/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
58 lines (49 loc) · 2.09 KB
/
init.lua
File metadata and controls
58 lines (49 loc) · 2.09 KB
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
-- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution
-- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk.
local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then
-- stylua: ignore
local result = vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
if vim.v.shell_error ~= 0 then
-- stylua: ignore
vim.api.nvim_echo({ { ("Error cloning lazy.nvim:\n%s\n"):format(result), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end
end
vim.opt.rtp:prepend(lazypath)
-- validate that lazy is available
if not pcall(require, "lazy") then
-- stylua: ignore
vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end
-- Disable annoying fold carrots
vim.api.nvim_create_autocmd("VimEnter" , { command = " set nofoldenable "})
-- Yank to clipboard
vim.opt.clipboard = "unnamedplus"
-- Remove trailing whitespace on save
vim.api.nvim_create_autocmd('BufWritePre', {
group = vim.api.nvim_create_augroup('TrimTrailingWhitespace', { clear = true }),
pattern = '*', -- Applies to all files
callback = function()
-- Save the current cursor position
local curpos = vim.api.nvim_win_get_cursor(0)
vim.cmd([[keeppatterns %s/\s\+$//e]])
vim.api.nvim_win_set_cursor(0, curpos)
end,
desc = 'Trim trailing whitespace on save and preserve cursor position',
})
-- See different named cmake files as still the cmake type
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "CMakeLists-*.txt",
command = "set filetype=cmake",
})
-- Enable xml highlighting for ROS .launch files
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "*.launch",
command = "set filetype=xml",
})
require "lazy_setup"
require "polish"