-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
203 lines (163 loc) · 5 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
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
-- Some "sensible defaults"
vim.o.termguicolors = true
vim.o.syntax = 'on'
vim.o.errorbells = false
vim.o.smartcase = true
vim.o.showmode = false
vim.bo.swapfile = false
vim.o.backup = false
vim.o.undodir = vim.fn.stdpath('config') .. '/undodir'
vim.o.undofile = true
vim.o.incsearch = true
vim.o.ignorecase = true
vim.o.hidden = true
vim.o.completeopt='menuone,noinsert,noselect'
vim.bo.autoindent = true
vim.bo.smartindent = true
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.signcolumn = 'yes'
vim.wo.wrap = false
-- Mappings
vim.g.mapleader = ','
local key_mapper = function(mode, key, result)
vim.api.nvim_set_keymap(
mode,
key,
result,
{noremap = true, silent = true}
)
end
-- Don't need no arrow keys
key_mapper('', '<up>', '<nop>')
key_mapper('', '<down>', '<nop>')
key_mapper('', '<left>', '<nop>')
key_mapper('', '<right>', '<nop>')
-- "Escape hatch"
key_mapper('i', 'jk', '<ESC>')
key_mapper('v', 'jk', '<ESC>')
-- My "fast save" and "fast quit"
key_mapper('', '<leader>w', ':w<CR>')
key_mapper('i', '<leader>w', '<C-o>:w<CR>')
key_mapper('', '<leader>q', ':q<CR>')
-- Load config file while editing
key_mapper('', '<leader>cl', ':luafile %<CR>')
-- Telescope mappings
key_mapper('', '<leader>ff', ':Telescope find_files<CR>')
key_mapper('', '<leader>fb', ':Telescope file_browser<CR>')
key_mapper('', '<leader>rg', ':Telescope live_grep<CR>')
key_mapper('', '<leader>bb', ':Telescope buffers<CR>')
key_mapper('', '<leader>lr', ':Telescope lsp_references<CR>')
key_mapper('', '<leader>ls', ':Telescope lsp_document_symbols<CR>')
key_mapper('', '<leader>lw', ':Telescope lsp_dynamic_workspace_symbols<CR>')
key_mapper('', '<leader>li', ':Telescope lsp_implementations<CR>')
key_mapper('', '<leader>ld', ':Telescope lsp_definitions<CR>')
key_mapper('', '<leader>jl', ':Telescope jumplist<CR>')
key_mapper('', '<leader>tk', ':Telescope keymaps<CR>')
-- Git aids
key_mapper('', '<leader>gm', ':GitMessenger<CR>')
-- Terminal keybindings
key_mapper('n', '<leader>tt', '<CMD>lua require("FTerm").toggle()<CR>')
key_mapper('t', '<leader>tt', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>')
-- LSP operations keybindings
key_mapper('', '<leader>ln', ':lua vim.lsp.buf.rename()<CR>')
key_mapper('', '<leader>lg', ':lua vim.lsp.buf.signature_help()<CR>')
-- Some helpers
local vim = vim
local execute = vim.api.nvim_command
local fn = vim.fn
-- ensure that packer is installed
local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path)
execute 'packadd packer.nvim'
end
vim.cmd('packadd packer.nvim')
-- Setting up plugins
local packer = require'packer'
local util = require'packer.util'
---- TODO: revisit this with current path
packer.init({
package_root = util.join_paths(vim.fn.stdpath('data'), 'site', 'pack')
})
-- List out plugins here
packer.startup(function()
local use = use
use 'nvim-treesitter/nvim-treesitter'
use 'sheerun/vim-polyglot'
-- these are optional themes but I hear good things about gloombuddy ;)
-- colorbuddy allows us to run the gloombuddy theme
use 'tjdevries/colorbuddy.nvim'
use 'bkegley/gloombuddy'
use 'neovim/nvim-lspconfig'
use 'anott03/nvim-lspinstall'
-- Browser
use 'nvim-lua/plenary.nvim'
use 'nvim-telescope/telescope.nvim'
use 'nvim-telescope/telescope-file-browser.nvim'
use 'rhysd/git-messenger.vim'
-- Go support
-- use 'ray-x/go.nvim'
-- use 'ray-x/guihua.lua' -- recommended if need floating window support
use 'lewis6991/gitsigns.nvim'
-- A terminal
use "numToStr/FTerm.nvim"
-- Comment niceties
use 'numToStr/Comment.nvim'
end
)
-- Color theme
-- vim.g.colors_name = 'koehler'
vim.cmd [[colorscheme gloombuddy]]
-- TreeSitter
---- TODO
-- LSP config
local lspconfig = require'lspconfig'
--local completion = require'completion'
--local function custom_on_attach(client)
-- print('Attaching to ' .. client.name)
-- completion.on_attach(client)
--end
--local default_config = {
-- on_attach = custom_on_attach,
--}
-- setup language servers here
lspconfig.tsserver.setup({})
lspconfig.gopls.setup({})
lspconfig.pylsp.setup({})
-- Telescope
require("telescope").setup {
extensions = {
file_browser = {
-- theme = "ivy",
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
mappings = {
["i"] = {
-- your custom insert mode mappings
},
["n"] = {
-- your custom normal mode mappings
},
},
},
},
}
-- To get telescope-file-browser loaded and working with telescope,
-- you need to call load_extension, somewhere after setup function:
require("telescope").load_extension "file_browser"
-- Git integration
require('gitsigns').setup()
-- Floating terminal
require'FTerm'.setup({
border = 'double',
dimensions = {
height = 0.9,
width = 0.9,
},
})
require('Comment').setup()