forked from nvim-lua/kickstart.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
181 lines (147 loc) Β· 5.15 KB
/
init.lua
File metadata and controls
181 lines (147 loc) Β· 5.15 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
-- This file is a main user config entry.
-- It's imported to main 'init.lua' at the bottom of file
--
-- User plugins are placed in 'lua/custom/plugins/init.lua' and imported to main 'init.lua'
-- inside its plugins require block (at the and of that block)
local nvim_config_folder = "~/.config/nvim/"
local config_path = "~/.config/nvim/lua/custom/config/init.lua"
local plugins_path = "~/.config/nvim/lua/custom/plugins/init.lua"
local global_config_path = "~/.config/nvim/init.lua"
local function open_config()
vim.cmd('e ' .. config_path)
end
local function open_plugins()
vim.cmd('e ' .. plugins_path)
end
local function open_global_config()
vim.cmd('e ' .. global_config_path)
end
local function table_contains(table_, value)
for _, element in ipairs(table_) do
if element == value then
return true
end
end
return false
end
local function map(mode, keys, action, etc)
etc = etc or {} -- Default value
vim.keymap.set(mode, keys, action, etc)
end
--------------------------------------------------------------------
-------------------- Plugin Configurations -------------------------
--------------------------------------------------------------------
require'lspconfig'.cssmodules_ls.setup {}
--------------------------------------------------------------------
require("autoclose").setup()
--------------------------------------------------------------------
require'nvim-treesitter.configs'.setup {
autotag = {
enable = true,
enable_rename = true,
enable_close = true,
enable_close_on_slash = true,
}
}
--------------------------------------------------------------------
-- local on_attach = function(client)
-- require'completion'.on_attach(client)
-- end
--
-- local util = require("lspconfig.util")
--
-- require"lspconfig".rust_analyzer.setup {
-- on_attach=on_attach,
-- settings = {
-- ["rust-analyzer"] = {
-- imports = {
-- granularity = {
-- group = "module",
-- },
-- prefix = "self",
-- },
-- cargo = {
-- buildScripts = {
-- enable = true,
-- },
-- },
-- procMacro = {
-- enable = true
-- },
-- }
-- }
-- }
--------------------------------------------------------------------
require("everforest").setup({
})
--------------------------------------------------------------------
local auto_dark_mode = require('auto-dark-mode')
auto_dark_mode.setup({
update_interval = 1000,
set_dark_mode = function()
vim.api.nvim_set_option('background', 'dark')
vim.cmd('colorscheme everforest')
end,
set_light_mode = function()
vim.api.nvim_set_option('background', 'light')
vim.cmd('colorscheme everforest')
end,
})
auto_dark_mode.init()
--------------------------------------------------------------------
local leap = require('leap')
leap.add_default_mappings()
--------------------------------------------------------------------
local rt = require("rust-tools")
rt.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
})
--------------------------------------------------------------------
------------------ Options and Keymappings -------------------------
--------------------------------------------------------------------
-- Limit cursor top and bottom position
vim.o.scrolloff = 10
vim.o.nu = true
vim.o.relativenumber = true
-- vim.cmd("colorscheme everforest")
require("lualine").setup({
options = {
-- ... other configuration
theme = "auto", -- Can also be "auto" to detect automatically.
}
})
-- Keymapping
map('n', '<leader>f', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
map('n', '<leader>co', open_config, { desc = '[C]onfig [O]pen' })
map('n', '<leader>cg', open_global_config, { desc = '[C]onfig [G]lobal open' })
map('n', '<leader>cp', open_plugins, { desc = '[C]onfig [P]lugins open' })
map('n', '<leader>cs', require('telescope.builtin').colorscheme, { desc = '[C]olor[S]cheme select' })
map('n', '<leader>t', function () vim.cmd("Telescope") end, { desc = 'Open [T]elescope' })
map('i', 'jk', function () vim.cmd("stopinsert") end, {})
map('n', 'gn', function () vim.cmd("bnext") end, { desc = '[G]o to [N]ext buffer' })
map('n', 'gp', function () vim.cmd("bprev") end, { desc = '[G]o to [P]revious buffer' })
vim.keymap.set({'n', 'v'}, 'f', function ()
local current_window = vim.fn.win_getid()
require('leap').leap { target_windows = { current_window } }
end)
-- Snippets
require("luasnip.loaders.from_vscode").lazy_load({ paths = { './snippets' } })
-- Wrap rules
local wrap_filetypes = {"markdown", "txt", "tex"}
vim.cmd("set nowrap")
if table_contains(wrap_filetypes, vim.bo.filetype) then
vim.cmd(":set wrap")
end
-- Tab size
vim.o.expandtab = true
vim.opt_global.tabstop = 4
vim.opt_global.shiftwidth = 4
vim.opt_global.softtabstop = 4
vim.cmd("source " .. nvim_config_folder .. "user.vim")