-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
111 lines (100 loc) · 3.98 KB
/
Copy pathinit.lua
File metadata and controls
111 lines (100 loc) · 3.98 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
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
local ts = {
lua = "lua",
python = "python",
javascript = "javascript",
typescript = "typescript",
html = "html",
css = "css",
json = "json",
sh = "bash",
zig = "zig",
odin = "odin",
go = "go",
gotmpl = "gotmpl",
c = "c",
cpp = "cpp",
rust = "rust",
}
vim.g.mapleader = " "
vim.g.fff = { lazy_sync = true, debug = { enabled = true, show_scores = true } }
vim.g.lean_config = { mappings = true }
vim.filetype.add({ extension = { gotmpl = "gotmpl", gohtml = "gotmpl" } })
vim.api.nvim_create_autocmd("PackChanged", {
group = vim.api.nvim_create_augroup("pack_changed", { clear = true }),
callback = function(ev)
local data = ev.data
local name = data.spec.name
if data.kind ~= "install" and data.kind ~= "update" then return end
if name == "fff" then
if not data.active then vim.cmd.packadd("fff") end
require("fff.download").download_or_build_binary()
end
if name == "nvim-treesitter" then
if not data.active then vim.cmd.packadd("nvim-treesitter") end
vim.cmd.TSUpdate()
end
end
})
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("ts_start", { clear = true }),
pattern = vim.tbl_keys(ts),
callback = function(ev)
local ok, err = pcall(vim.treesitter.start, ev.buf, ts[ev.match])
if not ok then vim.notify("treesitter: " .. tostring(err), vim.log.levels.WARN) end
end
})
local b = 'https://github.com/'
vim.pack.add({
b .. 'nvim-treesitter/nvim-treesitter',
b .. 'dmtrKovalenko/fff',
b .. 'nvim-tree/nvim-web-devicons',
b .. 'folke/snacks.nvim',
b .. 'Julian/lean.nvim',
b .. 'neovim/nvim-lspconfig',
})
require("snacks").setup( {image = { enabled = true }} )
require("nvim-treesitter").install(vim.tbl_values(ts))
vim.lsp.config("gopls", {
settings = { gopls = { templateExtensions = { "gotmpl", "gohtml" } } },
})
vim.lsp.config("lua_ls", {
on_init = function(client)
local ws = client.workspace_folders and client.workspace_folders[1]
if ws and ws.name ~= vim.fn.stdpath("config")
and (vim.uv.fs_stat(ws.name .. "/.luarc.json") or vim.uv.fs_stat(ws.name .. "/.luarc.jsonc")) then
return
end
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = { version = "LuaJIT", path = { "lua/?.lua", "lua/?/init.lua" } },
workspace = { checkThirdParty = false, library = { vim.env.VIMRUNTIME } },
})
end,
})
vim.lsp.enable({ "pyrefly", "gopls", "rust_analyzer", "tsc", "jsonls", "html", "cssls", "lua_ls" })
vim.o.termguicolors = true
vim.o.nu = true
vim.o.relativenumber = true
vim.o.clipboard = "unnamedplus"
vim.o.cursorline = true
vim.o.expandtab = true
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.swapfile = false
vim.o.backup = false
vim.o.wrap = false
vim.o.undofile = true
vim.o.undodir = os.getenv("HOME") .. "/.cache/nvim/undodir"
vim.fn.mkdir(vim.o.undodir, "p")
vim.o.list = true
vim.o.path = ".,,**"
vim.cmd("colorscheme retrobox")
local map = vim.keymap.set
map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
map("n", "<A-h>", ":below term<CR>i", { desc = "Open terminal below" })
map("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
map("n", "<leader>ff", function() require("fff").find_files() end, { desc = "FFF: Find files" })
map("n", "<leader>fg", function() require("fff").live_grep() end, { desc = "FFF: Live grep" })
map({ "n", "x" }, "<leader>fw", function() require("fff").live_grep_under_cursor() end, { desc = "FFF: Grep word or selection" })
map("n", "<leader>dq", vim.diagnostic.setqflist, { desc = "Diagnostics: all buffers to quickfix" })
map("n", "<leader>dl", vim.diagnostic.setloclist, { desc = "Diagnostics: this buffer to location list" })