feat: every vim plugins has its own file for commands / keybinds...
This commit is contained in:
parent
990a1cc518
commit
a87cc556f9
@ -1,28 +1,7 @@
|
||||
-- packages
|
||||
vim.cmd("packadd nvim-treesitter")
|
||||
require"nvim-treesitter.configs".setup {
|
||||
auto_install = true,
|
||||
highlight = {enable = true},
|
||||
}
|
||||
---------------------
|
||||
----- variables -----
|
||||
---------------------
|
||||
|
||||
vim.cmd("packadd black")
|
||||
|
||||
vim.cmd("packadd indent-blankline")
|
||||
require"indent_blankline".setup {
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
}
|
||||
|
||||
vim.cmd("packadd nvim-lspconfig")
|
||||
require"pack_lspconfig"
|
||||
|
||||
vim.cmd("packadd vim-dirdiff")
|
||||
|
||||
vim.cmd("packadd vim-easy-align")
|
||||
vim.keymap.set("n", "ga", "<Plug>(EasyAlign)")
|
||||
vim.keymap.set("x", "ga", "<Plug>(EasyAlign)<C-x>")
|
||||
|
||||
-- variables
|
||||
vim.g.mapleader = " "
|
||||
|
||||
vim.o.path = vim.o.path .. ",**"
|
||||
@ -52,14 +31,23 @@ vim.o.grepprg = "grep -rn"
|
||||
vim.o.scrolloff = 2
|
||||
vim.wo.cc = "80"
|
||||
|
||||
-- keybindings
|
||||
-- (mode, key, command )
|
||||
--------------------
|
||||
----- packages -----
|
||||
--------------------
|
||||
|
||||
require"pack-black"
|
||||
require"pack-indent-blankline"
|
||||
require"pack-lspconfig"
|
||||
require"pack-nvim-treesitter"
|
||||
require"pack-vim-dirdiff"
|
||||
require"pack-vim-easy-align"
|
||||
|
||||
-----------------------
|
||||
----- keybindings -----
|
||||
-----------------------
|
||||
|
||||
-- terminal escape key
|
||||
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>" )
|
||||
|
||||
-- go to file:line instead of just file
|
||||
vim.keymap.set("n", "gf", "gF" )
|
||||
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>" )
|
||||
|
||||
-- remove trailing whitespaces
|
||||
vim.keymap.set("n", "<Leader>w", "<cmd>%s/\\s\\+$//e<CR>")
|
||||
vim.keymap.set("n", "<Leader>w", "<cmd>%s/\\s\\+$//e<CR>")
|
||||
|
1
.config/nvim/lua/pack-black.lua
Normal file
1
.config/nvim/lua/pack-black.lua
Normal file
@ -0,0 +1 @@
|
||||
vim.cmd("packadd black")
|
5
.config/nvim/lua/pack-indent-blankline.lua
Normal file
5
.config/nvim/lua/pack-indent-blankline.lua
Normal file
@ -0,0 +1,5 @@
|
||||
vim.cmd("packadd indent-blankline")
|
||||
require"indent_blankline".setup {
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
}
|
45
.config/nvim/lua/pack-lspconfig.lua
Normal file
45
.config/nvim/lua/pack-lspconfig.lua
Normal file
@ -0,0 +1,45 @@
|
||||
vim.cmd("packadd nvim-lspconfig")
|
||||
|
||||
lspconfig = require"lspconfig"
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap=true, silent=true }
|
||||
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set("n", "<Leader>q", vim.diagnostic.setloclist, opts)
|
||||
|
||||
local servers = {
|
||||
"bashls",
|
||||
"dockerls",
|
||||
"pyright",
|
||||
"yamlls",
|
||||
}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup {
|
||||
on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set("n", "<Leader>wa", vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set("n", "<Leader>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set("n", "<Leader>wl", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set("n", "<Leader>D", vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
|
||||
end
|
||||
}
|
||||
end
|
5
.config/nvim/lua/pack-nvim-treesitter.lua
Normal file
5
.config/nvim/lua/pack-nvim-treesitter.lua
Normal file
@ -0,0 +1,5 @@
|
||||
vim.cmd("packadd nvim-treesitter")
|
||||
require"nvim-treesitter.configs".setup {
|
||||
auto_install = true,
|
||||
highlight = {enable = true},
|
||||
}
|
1
.config/nvim/lua/pack-vim-dirdiff.lua
Normal file
1
.config/nvim/lua/pack-vim-dirdiff.lua
Normal file
@ -0,0 +1 @@
|
||||
vim.cmd("packadd vim-dirdiff")
|
3
.config/nvim/lua/pack-vim-easy-align.lua
Normal file
3
.config/nvim/lua/pack-vim-easy-align.lua
Normal file
@ -0,0 +1,3 @@
|
||||
vim.cmd("packadd vim-easy-align")
|
||||
vim.keymap.set("n", "ga", "<Plug>(EasyAlign)")
|
||||
vim.keymap.set("x", "ga", "<Plug>(EasyAlign)")
|
@ -1,41 +0,0 @@
|
||||
lspconfig = require"lspconfig"
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap=true, silent=true }
|
||||
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set("n", "<Leader>q", vim.diagnostic.setloclist, opts)
|
||||
|
||||
local servers = {
|
||||
"bashls",
|
||||
"dockerls",
|
||||
"pyright",
|
||||
"yamlls",
|
||||
}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup{on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set("n", "<Leader>wa", vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set("n", "<Leader>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set("n", "<Leader>wl", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set("n", "<Leader>D", vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
|
||||
end}
|
||||
end
|
Loading…
Reference in New Issue
Block a user