-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
232 lines (218 loc) · 7.03 KB
/
Copy pathinit.lua
File metadata and controls
232 lines (218 loc) · 7.03 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
-- 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 = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
{
"shaunsingh/nord.nvim",
lazy = false,
priority = 1000,
config = function()
vim.g.nord_italic = false
vim.g.nord_bold = false
vim.cmd.colorscheme("nord")
end,
},
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {},
},
{
"nvim-treesitter/nvim-treesitter",
branch = "master",
lazy = false,
build = ":TSUpdate",
config = function()
require("nvim-treesitter.install").ts_generate_args = { "generate", "--abi", 14 }
require("nvim-treesitter.configs").setup({
ensure_installed = { "javascript", "typescript", "tsx", "swift", "objc", "lua", "vim", "vimdoc", "json" },
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
})
end,
},
{
"echasnovski/mini.files",
keys = {
{
"<C-e>",
function()
require("mini.files").open(vim.uv.cwd(), true)
end,
desc = "Open mini.files (cwd)",
},
},
},
{
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- calling `setup` is optional for customization
require("fzf-lua").setup({})
end,
keys = {
{
"<C-p>",
function()
require("fzf-lua").files()
end,
{ silent = true },
},
{
"<leader>gs",
function()
require("fzf-lua").git_status()
end,
{ silent = true },
desc = "status",
},
{
"<leader>p",
function()
require("fzf-lua").lsp_workspace_symbols()
end,
{ silent = true },
desc = "search symbols",
},
},
},
{
-- Autocompletion
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp", -- lsp completion source + capabilities
-- "hrsh7th/cmp-buffer", -- buffer completions
"hrsh7th/cmp-path", -- path completions
},
config = function()
local cmp = require("cmp")
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.complete(),
-- ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
}),
})
end,
},
{
"folke/ts-comments.nvim",
opts = {},
event = "VeryLazy",
enabled = vim.fn.has("nvim-0.10.0") == 1,
},
{
"stevearc/conform.nvim",
opts = {},
config = function()
require("conform").setup({
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_format = "fallback",
},
formatters_by_ft = {
lua = { "stylua" },
-- Conform will run the first available formatter
javascript = { "prettierd", "prettier", stop_after_first = true },
},
})
end,
},
{
"folke/flash.nvim",
event = "VeryLazy",
vscode = true,
---@type Flash.Config
opts = {},
-- stylua: ignore
keys = {
{ "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
{ "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
},
},
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
-- LSP
vim.lsp.config("*", {
capabilities = require("cmp_nvim_lsp").default_capabilities(),
})
vim.lsp.config("astro", {
cmd = { "astro-ls", "--stdio" },
filetypes = { "astro" },
root_markers = { "package.json", "tsconfig.json", "jsconfig.json", ".git" },
})
vim.lsp.config("vtsls", {
cmd = { "vtsls", "--stdio" },
filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact" },
root_markers = { "tsconfig.json", "jsconfig.json", "package.json", ".git" },
})
vim.lsp.config("sourcekit", {
cmd = { "xcrun", "sourcekit-lsp" },
filetypes = { "swift", "objc", "objcpp" },
root_markers = { "buildServer.json", "Package.swift", ".git" },
})
vim.lsp.enable({ "astro", "vtsls", "sourcekit" })
vim.opt.clipboard = "unnamedplus"
-- UI
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Relative line numbers
vim.opt.signcolumn = "yes" -- Always show signcolumn
vim.opt.cursorline = true -- Highlight current line
vim.opt.wrap = true -- Wrap lines
-- Indentation
vim.opt.expandtab = true -- Use spaces instead of tabs
vim.opt.shiftwidth = 2 -- Indent size
vim.opt.tabstop = 2 -- Tab size
vim.opt.smartindent = true -- Auto indent new lines
-- Search
vim.opt.ignorecase = true -- Ignore case when searching
vim.opt.smartcase = true -- Don't ignore case with capitals
vim.opt.hlsearch = true -- Highlight search results
vim.opt.incsearch = true -- Show search results as you type
-- Files
vim.opt.swapfile = false -- Don't use swapfile
vim.opt.backup = false -- Don't create backup files
vim.opt.undofile = true -- Persistent undo
vim.keymap.set("n", "<C-c>", ":cclose<CR>", { silent = true, desc = "Close quickfix" })
vim.keymap.set("n", "<Esc>", ":noh<CR>", { silent = true, desc = "Clear highlights" })
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover" })
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Goto Definition" })
vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "Find References" })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Code Action" })
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Rename" })