parent
ec8ee39e0e
commit
462f060207
@ -0,0 +1,8 @@
|
||||
require "custom.plugins"
|
||||
require "custom.options"
|
||||
require "custom.lsp"
|
||||
require "custom.utils"
|
||||
require "custom.treesitter"
|
||||
require "custom.keymaps"
|
||||
require "custom.whichkey"
|
||||
require "custom.nvim-tree"
|
@ -0,0 +1,70 @@
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
local term_opts = { silent = true }
|
||||
|
||||
-- Shorten function name
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
|
||||
--Map \ as leader key
|
||||
-- keymap("", "<Space>", "<Nop>", opts)
|
||||
vim.g.mapleader = '\\'
|
||||
vim.g.maplocalleader = '\\'
|
||||
|
||||
-- Modes
|
||||
-- normal_mode = "n",
|
||||
-- insert_mode = "i",
|
||||
-- visual_mode = "v",
|
||||
-- visual_block_mode = "x",
|
||||
-- term_mode = "t",
|
||||
-- command_mode = "c",
|
||||
|
||||
-- Normal --
|
||||
-- Better window navigation
|
||||
keymap("n", "<C-h>", "<C-w>h", opts)
|
||||
keymap("n", "<C-j>", "<C-w>j", opts)
|
||||
keymap("n", "<C-k>", "<C-w>k", opts)
|
||||
keymap("n", "<C-l>", "<C-w>l", opts)
|
||||
|
||||
-- Resize with arrows
|
||||
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
|
||||
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
|
||||
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
|
||||
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
|
||||
|
||||
-- Navigate buffers
|
||||
keymap("n", "<S-l>", ":bnext<CR>", opts)
|
||||
keymap("n", "<S-h>", ":bprevious<CR>", opts)
|
||||
|
||||
-- Move text up and down
|
||||
keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
|
||||
keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
|
||||
|
||||
-- Insert --
|
||||
-- Press jk fast to exit insert mode
|
||||
keymap("i", "jk", "<ESC>", opts)
|
||||
|
||||
-- Visual --
|
||||
-- Stay in indent mode
|
||||
keymap("v", "<", "<gv", opts)
|
||||
keymap("v", ">", ">gv", opts)
|
||||
|
||||
-- Move text up and down
|
||||
keymap("v", "<A-j>", ":m .+1<CR>==", opts)
|
||||
keymap("v", "<A-k>", ":m .-2<CR>==", opts)
|
||||
keymap("v", "p", '"_dP', opts)
|
||||
|
||||
-- Visual Block --
|
||||
-- Move text up and down
|
||||
keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
|
||||
keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
|
||||
keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
|
||||
keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)
|
||||
|
||||
-- Terminal --
|
||||
-- Better terminal navigation
|
||||
-- keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
|
||||
-- keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
|
||||
-- keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
|
||||
-- keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
local status_ok, nvim_tree = pcall(require, "nvim-tree")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
|
||||
if not config_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local tree_cb = nvim_tree_config.nvim_tree_callback
|
||||
|
||||
nvim_tree.setup {
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_cwd = true,
|
||||
},
|
||||
renderer = {
|
||||
root_folder_modifier = ":t",
|
||||
icons = {
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
folder = {
|
||||
arrow_open = "",
|
||||
arrow_closed = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "",
|
||||
staged = "S",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "U",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
show_on_dirs = true,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
side = "left",
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
|
||||
{ key = "h", cb = tree_cb "close_node" },
|
||||
{ key = "v", cb = tree_cb "vsplit" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
local options = {
|
||||
backup = false, -- creates a backup file
|
||||
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
|
||||
cmdheight = 2, -- more space in the neovim command line for displaying messages
|
||||
completeopt = { "menu", "menuone", "noselect" }, -- mostly just for cmp
|
||||
conceallevel = 0, -- so that `` is visible in markdown files
|
||||
fileencoding = "utf-8", -- the encoding written to a file
|
||||
hlsearch = true, -- highlight all matches on previous search pattern
|
||||
ignorecase = true, -- ignore case in search patterns
|
||||
mouse = "", -- allow the mouse to be used in neovim
|
||||
pumheight = 10, -- pop up menu height
|
||||
showmode = true, -- we don't need to see things like -- INSERT -- anymore
|
||||
showtabline = 2, -- always show tabs
|
||||
smartcase = true, -- smart case
|
||||
smartindent = true, -- make indenting smarter again
|
||||
splitbelow = true, -- force all horizontal splits to go below current window
|
||||
splitright = true, -- force all vertical splits to go to the right of current window
|
||||
swapfile = false, -- creates a swapfile
|
||||
-- termguicolors = true, -- set term gui colors (most terminals support this)
|
||||
timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||
undofile = true, -- enable persistent undo
|
||||
updatetime = 300, -- faster completion (4000ms default)
|
||||
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
|
||||
expandtab = true, -- convert tabs to spaces
|
||||
shiftwidth = 4, -- the number of spaces inserted for each indentation
|
||||
tabstop = 4, -- insert 2 spaces for a tab
|
||||
cursorline = true, -- highlight the current line
|
||||
number = true, -- set numbered lines
|
||||
relativenumber = false, -- set relative numbered lines
|
||||
numberwidth = 4, -- set number column width to 2 {default 4}
|
||||
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
|
||||
wrap = false, -- display lines as one long line
|
||||
scrolloff = 8, -- is one of my fav
|
||||
sidescrolloff = 8,
|
||||
guifont = "monospace:h17", -- the font used in graphical neovim applications
|
||||
}
|
||||
|
||||
vim.opt.shortmess:append "c"
|
||||
|
||||
for k, v in pairs(options) do
|
||||
vim.opt[k] = v
|
||||
end
|
||||
|
||||
vim.cmd "set whichwrap+=<,>,[,],h,l"
|
||||
vim.cmd [[set iskeyword+=-]]
|
@ -0,0 +1,27 @@
|
||||
local Plug = vim.fn['plug#']
|
||||
vim.call('plug#begin', '~/.local/share/nvim/plugged/')
|
||||
Plug 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/cmp-cmdline'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'folke/which-key.nvim'
|
||||
Plug 'hrsh7th/cmp-nvim-lua'
|
||||
Plug 'hrsh7th/cmp-path'
|
||||
Plug 'hrsh7th/cmp-vsnip'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
Plug 'hrsh7th/vim-vsnip'
|
||||
Plug 'mrk21/yaml-vim' -- For hieradata
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'nvim-lua/completion-nvim'
|
||||
Plug 'nvim-lua/diagnostic-nvim'
|
||||
Plug 'windwp/nvim-autopairs'
|
||||
Plug 'kyazdani42/nvim-tree.lua'
|
||||
Plug 'nvim-lua/plenary.nvim' -- Dependecy for telescope
|
||||
Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'}) -- Dependecy for telescope
|
||||
Plug 'nvim-lua/telescope.nvim'
|
||||
Plug 'rodjek/vim-puppet'
|
||||
Plug 'tpope/vim-surround'
|
||||
Plug 'vim-ruby/vim-ruby' -- For Facts, Ruby functions, and custom providers
|
||||
Plug 'williamboman/nvim-lsp-installer'
|
||||
Plug('preservim/nerdtree', { on = {'NERDTreeToggle', 'NERDTree' }})
|
||||
vim.call('plug#end')
|
@ -0,0 +1,24 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
ensure_installed = "maintained",
|
||||
|
||||
-- Install languages synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- List of parsers to ignore installing
|
||||
ignore_install = { "javascript" },
|
||||
|
||||
highlight = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
|
||||
-- list of language that will be disabled
|
||||
disable = { "c", "rust" },
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
vim.cmd([[if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
endif]])
|
@ -0,0 +1,188 @@
|
||||
local status_ok, which_key = pcall(require, "which-key")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local setup = {
|
||||
plugins = {
|
||||
marks = true, -- shows a list of your marks on ' and `
|
||||
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
||||
spelling = {
|
||||
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
|
||||
suggestions = 20, -- how many suggestions should be shown in the list?
|
||||
},
|
||||
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
|
||||
-- No actual key bindings are created
|
||||
presets = {
|
||||
operators = false, -- adds help for operators like d, y, ... and registers them for motion / text object completion
|
||||
motions = true, -- adds help for motions
|
||||
text_objects = true, -- help for text objects triggered after entering an operator
|
||||
windows = true, -- default bindings on <c-w>
|
||||
nav = true, -- misc bindings to work with windows
|
||||
z = true, -- bindings for folds, spelling and others prefixed with z
|
||||
g = true, -- bindings for prefixed with g
|
||||
},
|
||||
},
|
||||
-- add operators that will trigger motion and text object completion
|
||||
-- to enable all native operators, set the preset / operators plugin above
|
||||
-- operators = { gc = "Comments" },
|
||||
key_labels = {
|
||||
-- override the label used to display some keys. It doesn't effect WK in any other way.
|
||||
-- For example:
|
||||
-- ["<space>"] = "SPC",
|
||||
-- ["<cr>"] = "RET",
|
||||
-- ["<tab>"] = "TAB",
|
||||
},
|
||||
icons = {
|
||||
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
|
||||
separator = "➜", -- symbol used between a key and it's label
|
||||
group = "+", -- symbol prepended to a group
|
||||
},
|
||||
popup_mappings = {
|
||||
scroll_down = "<c-d>", -- binding to scroll down inside the popup
|
||||
scroll_up = "<c-u>", -- binding to scroll up inside the popup
|
||||
},
|
||||
window = {
|
||||
border = "rounded", -- none, single, double, shadow
|
||||
position = "bottom", -- bottom, top
|
||||
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
|
||||
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
|
||||
winblend = 0,
|
||||
},
|
||||
layout = {
|
||||
height = { min = 4, max = 25 }, -- min and max height of the columns
|
||||
width = { min = 20, max = 50 }, -- min and max width of the columns
|
||||
spacing = 3, -- spacing between columns
|
||||
align = "left", -- align columns left, center or right
|
||||
},
|
||||
ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label
|
||||
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
|
||||
show_help = true, -- show help message on the command line when the popup is visible
|
||||
triggers = "auto", -- automatically setup triggers
|
||||
-- triggers = {"<leader>"} -- or specify a list manually
|
||||
triggers_blacklist = {
|
||||
-- list of mode / prefixes that should never be hooked by WhichKey
|
||||
-- this is mostly relevant for key maps that start with a native binding
|
||||
-- most people should not need to change this
|
||||
i = { "j", "k" },
|
||||
v = { "j", "k" },
|
||||
},
|
||||
}
|
||||
|
||||
local opts = {
|
||||
mode = "n", -- NORMAL mode
|
||||
prefix = "<leader>",
|
||||
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
|
||||
silent = true, -- use `silent` when creating keymaps
|
||||
noremap = true, -- use `noremap` when creating keymaps
|
||||
nowait = true, -- use `nowait` when creating keymaps
|
||||
}
|
||||
|
||||
local mappings = {
|
||||
["a"] = { "<cmd>Alpha<cr>", "Alpha" },
|
||||
["b"] = {
|
||||
"<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})<cr>",
|
||||
"Buffers",
|
||||
},
|
||||
["e"] = { "<cmd>NvimTreeToggle<cr>", "Explorer" },
|
||||
["w"] = { "<cmd>w!<CR>", "Save" },
|
||||
["q"] = { "<cmd>q!<CR>", "Quit" },
|
||||
["c"] = { "<cmd>Bdelete!<CR>", "Close Buffer" },
|
||||
["h"] = { "<cmd>nohlsearch<CR>", "No Highlight" },
|
||||
["f"] = {
|
||||
"<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})<cr>",
|
||||
"Find files",
|
||||
},
|
||||
["F"] = { "<cmd>Telescope live_grep theme=ivy<cr>", "Find Text" },
|
||||
["P"] = { "<cmd>lua require('telescope').extensions.projects.projects()<cr>", "Projects" },
|
||||
|
||||
p = {
|
||||
name = "Packer",
|
||||
c = { "<cmd>PackerCompile<cr>", "Compile" },
|
||||
i = { "<cmd>PackerInstall<cr>", "Install" },
|
||||
s = { "<cmd>PackerSync<cr>", "Sync" },
|
||||
S = { "<cmd>PackerStatus<cr>", "Status" },
|
||||
u = { "<cmd>PackerUpdate<cr>", "Update" },
|
||||
},
|
||||
|
||||
g = {
|
||||
name = "Git",
|
||||
g = { "<cmd>lua _LAZYGIT_TOGGLE()<CR>", "Lazygit" },
|
||||
j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" },
|
||||
k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" },
|
||||
l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
|
||||
p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
|
||||
r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
|
||||
R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
|
||||
s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
|
||||
u = {
|
||||
"<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
|
||||
"Undo Stage Hunk",
|
||||
},
|
||||
o = { "<cmd>Telescope git_status<cr>", "Open changed file" },
|
||||
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
|
||||
c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" },
|
||||
d = {
|
||||
"<cmd>Gitsigns diffthis HEAD<cr>",
|
||||
"Diff",
|
||||
},
|
||||
},
|
||||
|
||||
l = {
|
||||
name = "LSP",
|
||||
a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" },
|
||||
d = {
|
||||
"<cmd>Telescope lsp_document_diagnostics<cr>",
|
||||
"Document Diagnostics",
|
||||
},
|
||||
w = {
|
||||
"<cmd>Telescope lsp_workspace_diagnostics<cr>",
|
||||
"Workspace Diagnostics",
|
||||
},
|
||||
f = { "<cmd>lua vim.lsp.buf.format{async=true}<cr>", "Format" },
|
||||
i = { "<cmd>LspInfo<cr>", "Info" },
|
||||
I = { "<cmd>LspInstallInfo<cr>", "Installer Info" },
|
||||
j = {
|
||||
"<cmd>lua vim.lsp.diagnostic.goto_next()<CR>",
|
||||
"Next Diagnostic",
|
||||
},
|
||||
k = {
|
||||
"<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>",
|
||||
"Prev Diagnostic",
|
||||
},
|
||||
l = { "<cmd>lua vim.lsp.codelens.run()<cr>", "CodeLens Action" },
|
||||
q = { "<cmd>lua vim.lsp.diagnostic.set_loclist()<cr>", "Quickfix" },
|
||||
r = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" },
|
||||
s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },
|
||||
S = {
|
||||
"<cmd>Telescope lsp_dynamic_workspace_symbols<cr>",
|
||||
"Workspace Symbols",
|
||||
},
|
||||
},
|
||||
s = {
|
||||
name = "Search",
|
||||
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
|
||||
c = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" },
|
||||
h = { "<cmd>Telescope help_tags<cr>", "Find Help" },
|
||||
M = { "<cmd>Telescope man_pages<cr>", "Man Pages" },
|
||||
r = { "<cmd>Telescope oldfiles<cr>", "Open Recent File" },
|
||||
R = { "<cmd>Telescope registers<cr>", "Registers" },
|
||||
k = { "<cmd>Telescope keymaps<cr>", "Keymaps" },
|
||||
C = { "<cmd>Telescope commands<cr>", "Commands" },
|
||||
},
|
||||
|
||||
t = {
|
||||
name = "Terminal",
|
||||
n = { "<cmd>lua _NODE_TOGGLE()<cr>", "Node" },
|
||||
u = { "<cmd>lua _NCDU_TOGGLE()<cr>", "NCDU" },
|
||||
t = { "<cmd>lua _HTOP_TOGGLE()<cr>", "Htop" },
|
||||
p = { "<cmd>lua _PYTHON_TOGGLE()<cr>", "Python" },
|
||||
f = { "<cmd>ToggleTerm direction=float<cr>", "Float" },
|
||||
h = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", "Horizontal" },
|
||||
v = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", "Vertical" },
|
||||
},
|
||||
}
|
||||
|
||||
which_key.setup(setup)
|
||||
which_key.register(mappings, opts)
|
||||
|
Loading…
Reference in new issue