-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
176 lines (144 loc) · 5.34 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
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
-- nvim-tree says to do this:
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- **********************************************
-- Pull in lazy.vim if not already installed
-- **********************************************
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Map leader and local leader
vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
vim.g.maplocalleader = "\\" -- Same for `maplocalleader`
-- **********************************************
-- Configure options
-- **********************************************
-- [[ Tab / Indentation ]]
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.wrap = false
-- [[ Clipboard ]]
-- vim.opt.clipboard = "unnamedplus" -- str: Use the system clipboard
-- [[ Line Numbers ]]
vim.opt.number = true -- bool: Show line numbers
vim.opt.relativenumber = false -- bool: Show line numbers relative to the line with the cursor
-- [[ Behavior ]]
vim.opt.errorbells = false
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undofile = false
vim.opt.scrolloff = 10
vim.opt.virtualedit = "block"
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- [[ Theme ]]
vim.opt.syntax = "ON" -- str: Allow syntax highlighting
vim.opt.termguicolors = true -- bool: If term supports ui color then enable
-- **********************************************
-- Configure plugins
-- **********************************************
ThemePlugin = "marcusrugger/catppuccin-nvim"
ThemeName = "catppuccin-dark"
-- ThemePlugin = "rebelot/kanagawa.nvim"
-- ThemeName = "kanagawa-wave"
local lazy_plugins = {
{ import = "plugins" },
{ import = "themes" },
}
local lazy_options = {
defaults = {
lazy = true,
},
rtp = {
disabled_plugins = {
},
},
change_detection = {
notify = false,
},
install = {
missing = true,
colorscheme = { ThemeName },
},
}
require("lazy").setup(lazy_plugins, lazy_options)
-- Setup for Toggleterm
require("toggleterm").setup()
vim.cmd [[let &shell = '"C:\Program Files\Git\bin\bash.exe"']]
vim.cmd [[let &shellcmdflag = '-s']]
-- **********************************************
-- Configure keymap
-- **********************************************
-- nvim-tree
vim.keymap.set('n', "<leader>n", ":NvimTreeToggle<cr>")
-- vim.keymap.set('n', "<C-j>", "<C-e>")
-- vim.keymap.set('n', "<C-k>", "<C-y>")
vim.keymap.set('n', "<C-h>", "<C-w>h")
vim.keymap.set('n', "<C-l>", "<C-w>l")
local nvimtree = require('nvim-tree.api')
vim.keymap.set('n', '<leader>b', function()
nvimtree.tree.find_file({ open = true })
end, { desc = "Find file in NvimTree" })
-- **********************************************
-- Additional things
-- **********************************************
vim.api.nvim_create_autocmd("FileType", {
pattern = { "json", "lua", "nix", "python", "sh", "yaml" },
callback = function()
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
end,
})
vim.cmd.colorscheme(ThemeName)
-- **********************************************
-- LSP Keymap
-- **********************************************
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', ":Telescope lsp_definitions<cr>", opts) -- vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', ":Telescope lsp_references<cr>", opts) -- vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})