feat: refactor
This commit is contained in:
32
configs/nvim/lua/core/autocommands.lua
Normal file
32
configs/nvim/lua/core/autocommands.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local cmd = vim.cmd
|
||||
|
||||
cmd [[
|
||||
augroup highlight_yank
|
||||
au!
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 150 }
|
||||
augroup END
|
||||
]]
|
||||
|
||||
cmd [[
|
||||
augroup filetypedetect
|
||||
au BufNewFile,BufRead *.frag setl ft=glsl
|
||||
au BufNewFile,BufRead *.vert setl ft=glsl
|
||||
augroup END
|
||||
]]
|
||||
|
||||
cmd [[
|
||||
augroup SaveManualFolds
|
||||
autocmd!
|
||||
au BufWinLeave, BufLeave ?* silent! mkview
|
||||
au BufWinEnter ?* silent! loadview
|
||||
augroup END
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre",{
|
||||
callback = function()
|
||||
vim.lsp.buf.formatting_sync();
|
||||
end
|
||||
})
|
86
configs/nvim/lua/core/keymappings.lua
Normal file
86
configs/nvim/lua/core/keymappings.lua
Normal file
@@ -0,0 +1,86 @@
|
||||
local map = vim.api.nvim_set_keymap
|
||||
local g = vim.g
|
||||
|
||||
local options = {noremap = true}
|
||||
local remap = {noremap = false}
|
||||
|
||||
g.mapleader = " "
|
||||
|
||||
map("n", "<C-o>", ":Telescope find_files<CR>", options)
|
||||
map("n", "<C-f>", ":Telescope live_grep<CR>", options)
|
||||
map("n","<C-p>",":Telescope command_center<CR>",options)
|
||||
map("n", "<Shift>", "za", options)
|
||||
|
||||
-- LSP Functionality
|
||||
map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", options)
|
||||
map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", options)
|
||||
map("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", options)
|
||||
map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", options)
|
||||
map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", options)
|
||||
map("n", "<Leader>e", "<cmd>lua vim.diagnostic.open_float()<CR>", options)
|
||||
map("n", "<Leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", options)
|
||||
map("n", "<Leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>", options)
|
||||
-- map("n", "<Leader><C-f>", ":Neoformat<CR>", options)
|
||||
map("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", options)
|
||||
map("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", options)
|
||||
map("n", "<leader>t", ":TroubleToggle<CR>", remap)
|
||||
|
||||
-- Navigate Buffers
|
||||
map("n", "<C-h>", "<C-w>h", options)
|
||||
map("n", "<C-j>", "<C-w>j", options)
|
||||
map("n", "<C-k>", "<C-w>k", options)
|
||||
map("n", "<C-l>", "<C-w>l", options)
|
||||
|
||||
-- Browser like next/previous
|
||||
map("n", "<A-Left>", ":bprevious<CR>",options);
|
||||
map("n", "<A-Right>", ":bnext<CR>",options);
|
||||
|
||||
-- Backspace Delete like Browser
|
||||
map('i', '<C-H>', '<Esc>caw', options)
|
||||
|
||||
map("n", "Y", "yy", options)
|
||||
map("n", "<Leader>k", "{", options)
|
||||
map("n", "<Leader>j", "}", options)
|
||||
|
||||
-- Move lines vscode style
|
||||
map("n", "<A-j>", "<cmd>move +1<CR>", options)
|
||||
map("n", "<A-k>", "<cmd>move -2<CR>", options)
|
||||
map("i", "<A-j>", "<cmd>move +1<CR>", options)
|
||||
map("i", "<A-k>", "<cmd>move -2<CR>", options)
|
||||
map("v", "<A-j>", ":m '>+1<CR>gv=gv", options)
|
||||
map("v", "<A-k>", ":m '<-2<CR>gv=gv", options)
|
||||
map("n", "<A-S-k>", "YP", options)
|
||||
map("n", "<A-S-j>", "Yp", options)
|
||||
|
||||
-- Faster git merge
|
||||
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options)
|
||||
map("n", "<Leader>gdl", ":diffget //3<CR>", options)
|
||||
map("n", "<Leader>gdh", ":diffget //2<CR>", options)
|
||||
|
||||
-- Find file in NvimTree
|
||||
map("n", "<Leader>f", ":NvimTreeFindFile<CR><c-w>", options)
|
||||
|
||||
map("n", "<C-->",":vsplit<CR>",options);
|
||||
map("n", "<C-|>",":split<CR>",options);
|
||||
|
||||
-- I aint no weak boy
|
||||
map("n", "<Left>", ":echo 'No Left for you'<CR><i><dw>", options)
|
||||
map("n", "<Right>", ":echo 'No Right for you'<CR><dw>", options)
|
||||
map("n", "<Up>", ":echo 'No Up for you'<CR><dw>", options)
|
||||
map("n", "<Down>", ":echo 'No Down for you'<CR><dw>", options)
|
||||
|
||||
-- Run Requests
|
||||
map("n", "<Leader>r", "<cmd>lua require('rest-nvim').run()<CR>", options)
|
||||
|
||||
-- Close on q
|
||||
map("n", "<Leader>q", "<Esc>:q<CR>", options)
|
||||
|
||||
-- Open Nerdtree
|
||||
map("n", "<C-n>", ":NvimTreeToggle<CR>", options)
|
||||
|
||||
-- Make ctrl+s work
|
||||
map("n", "<C-s>", "<Esc>:w<CR>", options)
|
||||
map("i", "<C-s>", "<Esc>:w<CR>i", options)
|
||||
|
||||
-- Update vim config
|
||||
map("n", "<C-u>", "<Esc>:source $MYVIMRC<CR>", options)
|
63
configs/nvim/lua/core/options.lua
Normal file
63
configs/nvim/lua/core/options.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
-------------
|
||||
-- General --
|
||||
-------------
|
||||
local set = vim.opt
|
||||
set.swapfile = false -- Don't use swapfile
|
||||
set.updatetime = 0 -- Faster completion
|
||||
set.encoding="utf-8" -- The encoding displayed
|
||||
set.fileencoding="utf-8" -- The encoding written to file
|
||||
set.smartindent = true -- Makes indenting smart
|
||||
set.iskeyword:append("-") -- treat dash separated words as a word text object"
|
||||
set.clipboard = "unnamedplus" -- Copy paste between vim and everything else
|
||||
set.smarttab = true -- Makes tabbing smarter will realize you have 2 vs 4
|
||||
set.expandtab = true -- Converts tabs to spaces
|
||||
set.autoindent = true -- Good auto indent
|
||||
set.autochdir = true -- Your working directory will always be the same as your working directory
|
||||
set.incsearch = true -- sets incremental search
|
||||
set.shell = "/bin/zsh" -- Set your shell to bash or zsh
|
||||
set.shortmess:append "sI" -- Disable nvim intro
|
||||
vim.cmd [[set nobackup]] -- creates a backup file
|
||||
vim.cmd [[set nowritebackup]] -- creates a backup file i guess
|
||||
vim.cmd [[set formatoptions-=cro]] -- Stop newline continution of comments
|
||||
vim.cmd [[set complete+=kspell]] -- auto complete with spellcheck
|
||||
vim.cmd [[set completeopt=menuone,longest]] -- auto complete menu (It's pretty great)
|
||||
vim.cmd [[set nocompatible]] -- Disable compatibility to old-time vi
|
||||
set.mouse = 'a' -- Enable mouse support
|
||||
|
||||
---------------
|
||||
-- Neovim UI --
|
||||
---------------
|
||||
set.pumheight = 15 -- Makes popup menu smaller
|
||||
set.ruler = true -- Show the cursor position all the time
|
||||
set.splitbelow = true -- Horizontal splits will automatically be below
|
||||
set.splitright = true -- Vertical splits will automatically be to the right
|
||||
set.conceallevel = 0 -- So that I can see `` in markdown files
|
||||
set.tabstop = 2 -- Insert 2 spaces for a tab
|
||||
set.number = true -- Line numbers
|
||||
set.background = "dark" -- tell vim what the background color looks like
|
||||
set.virtualedit = "onemore" -- With This option you can move the cursor one character over the end
|
||||
set.ignorecase = true -- ignores case when searching
|
||||
set.smartcase = true -- turns on case sensitive search when letters are capitalized
|
||||
set.termguicolors = true -- set term gui colors (most terminals support this)
|
||||
set.laststatus=2 -- Always display the status line
|
||||
set.title = true -- Show current txt that you editing
|
||||
set.relativenumber = false -- Vim’s absolute, relative and hybrid line numbers
|
||||
set.cursorline = false -- Enable highlighting of the current line
|
||||
set.shiftwidth = 2 -- Change the number of space characters inserted for indentation
|
||||
set.showtabline = 1 -- Always show tabs
|
||||
set.cmdheight = 1 -- More space for displaying messages
|
||||
vim.cmd [[set nowrap]] -- Display long lines as just one line
|
||||
vim.cmd [[set noshowmode]] -- We don't need to see things like -- INSERT -- anymore
|
||||
vim.cmd [[syntax enable]] -- Enables syntax highlighing
|
||||
vim.cmd [[set t_Co=256]] -- Support 256 colors
|
||||
-- vim.cmd "set whichwrap+=<,>,[,],h,l" -- Breaks Space-Time Continuum
|
||||
|
||||
-----------------
|
||||
-- Memory, CPU --
|
||||
-----------------
|
||||
set.hidden = true -- Required to keep multiple buffers open multiple buffers
|
||||
set.timeoutlen = 500 -- By default timeoutlen is 1000 ms
|
||||
set.lazyredraw = true -- Disable lazyredraw
|
||||
set.synmaxcol = 240 -- Max column for syntax highlight
|
||||
set.updatetime = 700 -- ms to wait for trigger an event
|
96
configs/nvim/lua/core/plugins.lua
Normal file
96
configs/nvim/lua/core/plugins.lua
Normal file
@@ -0,0 +1,96 @@
|
||||
return require("packer").startup(
|
||||
function(use)
|
||||
-- Let packer manage itself
|
||||
use "wbthomason/packer.nvim"
|
||||
|
||||
use 'lewis6991/impatient.nvim'
|
||||
|
||||
-- General Helper Functions
|
||||
use "nvim-lua/plenary.nvim"
|
||||
|
||||
-- Filetype Detection
|
||||
-- use "nathom/filetype.nvim"
|
||||
|
||||
-- Theming Section
|
||||
-- use 'folke/tokyonight.nvim'
|
||||
use "EdenEast/nightfox.nvim"
|
||||
use "nvim-lualine/lualine.nvim"
|
||||
-- use "xiyaowong/nvim-transparent"
|
||||
|
||||
-- Layout Plugins
|
||||
use "kyazdani42/nvim-web-devicons"
|
||||
use "kyazdani42/nvim-tree.lua"
|
||||
use "nvim-lua/popup.nvim"
|
||||
use "mhinz/vim-startify"
|
||||
-- use "tpope/vim-fugitive"
|
||||
use "tpope/vim-commentary"
|
||||
-- use "tpope/vim-surround"
|
||||
-- use "lambdalisue/suda.vim"
|
||||
use "windwp/nvim-autopairs"
|
||||
|
||||
-- Code Navigation
|
||||
-- use "alexghergh/nvim-tmux-navigation"
|
||||
-- use "dense-analysis/ale"
|
||||
-- use "nathanmsmith/nvim-ale-diagnostic"
|
||||
use "junegunn/fzf"
|
||||
use "nvim-telescope/telescope.nvim"
|
||||
use "gfeiyou/command-center.nvim"
|
||||
|
||||
-- Postman like features
|
||||
-- use "NTBBloodbath/rest.nvim"
|
||||
|
||||
-- Obsidian / Roam like features
|
||||
-- use "lervag/wiki.vim"
|
||||
|
||||
use "rcarriga/nvim-notify"
|
||||
|
||||
-- Lsp Errors
|
||||
use "folke/lsp-colors.nvim"
|
||||
use "kosayoda/nvim-lightbulb"
|
||||
-- use "onsails/lspkind-nvim"
|
||||
use {
|
||||
"folke/trouble.nvim",
|
||||
requires = "kyazdani42/nvim-web-devicons",
|
||||
config = function()
|
||||
require("trouble").setup {}
|
||||
end
|
||||
}
|
||||
|
||||
-- Syntax / Autocomplete
|
||||
-- use "terminalnode/sway-vim-syntax" --sway config syntax
|
||||
use "neovim/nvim-lspconfig"
|
||||
use "hrsh7th/nvim-cmp"
|
||||
use "hrsh7th/cmp-nvim-lsp"
|
||||
use "hrsh7th/cmp-nvim-lua"
|
||||
use "hrsh7th/cmp-path"
|
||||
use "hrsh7th/cmp-calc"
|
||||
use "hrsh7th/cmp-buffer"
|
||||
use "hrsh7th/cmp-cmdline"
|
||||
use "rafamadriz/friendly-snippets"
|
||||
use "L3MON4D3/LuaSnip"
|
||||
use "saadparwaiz1/cmp_luasnip"
|
||||
use "williamboman/nvim-lsp-installer"
|
||||
use "nvim-lua/lsp-status.nvim"
|
||||
-- use "jose-elias-alvarez/nvim-lsp-ts-utils"
|
||||
-- use "neoclide/jsonc.vim"
|
||||
use "brymer-meneses/grammar-guard.nvim"
|
||||
use {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
run = ":TSUpdate"
|
||||
}
|
||||
|
||||
-- Autoformat
|
||||
-- use "sbdchd/neoformat"
|
||||
use "lukas-reineke/lsp-format.nvim"
|
||||
-- use "lukas-reineke/format.nvim"
|
||||
|
||||
-- General Popup Window
|
||||
use "akinsho/nvim-toggleterm.lua"
|
||||
|
||||
use "rktjmp/fwatch.nvim"
|
||||
|
||||
-- Database Feature
|
||||
use "tpope/vim-dadbod"
|
||||
use "kristijanhusak/vim-dadbod-ui"
|
||||
end
|
||||
)
|
Reference in New Issue
Block a user