diff options
author | Brahmajit Das <brahmajit.xyz@gmail.com> | 2024-12-29 13:55:26 +0530 |
---|---|---|
committer | Brahmajit Das <brahmajit.xyz@gmail.com> | 2024-12-29 13:55:26 +0530 |
commit | 0b5f3fc96eddcd603de17644da8a962e0a93c04a (patch) | |
tree | 60a87da847c30120722b75aed3d025a0ed5e929d /plugin | |
parent | 5b62a6fdcaf0604d1234a89d0629680ca77317a5 (diff) |
moving global settings to plugin folder, for autoloading
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/appearance.lua | 53 | ||||
-rw-r--r-- | plugin/basics.lua | 89 | ||||
-rw-r--r-- | plugin/keymaps.lua | 61 | ||||
-rw-r--r-- | plugin/utils.lua | 17 |
4 files changed, 220 insertions, 0 deletions
diff --git a/plugin/appearance.lua b/plugin/appearance.lua new file mode 100644 index 0000000..3151523 --- /dev/null +++ b/plugin/appearance.lua @@ -0,0 +1,53 @@ +local opt = vim.opt -- Set options (global/buffer/windows-scoped) + +----------------------------------------------------------- +-- Neovim UI +----------------------------------------------------------- +opt.number = true -- Show line number +opt.relativenumber = true -- Show relative line number +opt.showmatch = true -- Highlight matching parenthesis +opt.foldmethod = 'marker' -- Enable folding (default 'foldmarker') +opt.splitright = true -- Vertical split to the right +opt.splitbelow = true -- Horizontal split to the bottom +opt.ignorecase = true -- Ignore case letters when search +opt.smartcase = true -- Ignore lowercase for the whole pattern +opt.linebreak = true -- Wrap on word boundary +opt.termguicolors = true -- Enable 24-bit RGB colors +opt.laststatus = 2 -- Set global statusline +opt.colorcolumn = "120" -- Set global color column +opt.splitbelow = true +opt.splitright = true +opt.scrolloff = 2 +opt.sidescrolloff = 5 +opt.foldlevelstart = 99 +opt.ruler = false +opt.list = true +opt.showtabline = 0 +opt.winwidth = 30 +opt.winminwidth = 10 +opt.pumheight = 15 +opt.helpheight = 12 +opt.previewheight = 12 +opt.showcmd = false +opt.listchars = 'tab:░ ,extends:›,precedes:‹,nbsp:·,trail:·' +opt.background = 'dark' +opt.cmdheight = 2 +opt.fillchars = { + diff = "╱", + vert = "│", + fold = "⠀", + eob = " ", -- suppress ~ at EndOfBuffer + --diff = "⣿", -- alternatives = ⣿ ░ ─ ╱ + msgsep = "‾", + foldopen = "▾", + foldsep = "│", + foldclose = "▸", +} + +vim.cmd [[ + " Function, identifier and comments in italic + highlight Function cterm=italic gui=italic + highlight Indentifier cterm=none gui=italic + highlight Comment cterm=italic gui=italic +]] +vim.cmd [[ "syntax sync fromstart" ]] diff --git a/plugin/basics.lua b/plugin/basics.lua new file mode 100644 index 0000000..66e53fa --- /dev/null +++ b/plugin/basics.lua @@ -0,0 +1,89 @@ +----------------------------------------------------------- +-- General Neovim settings and configuration +----------------------------------------------------------- + +local g = vim.g -- Global variables +local opt = vim.opt -- Set options (global/buffer/windows-scoped) +local cache_dir = os.getenv('HOME') .. '/.cache/nvim/' + +----------------------------------------------------------- +-- General +----------------------------------------------------------- +opt.mouse = 'a' -- Enable mouse support +opt.swapfile = false -- Don't use swapfile +opt.completeopt = 'menuone,noinsert,noselect' -- Autocomplete options +opt.history = 500 -- Lines vim should remember +opt.backup = false +opt.writebackup = false +opt.shell = 'zsh' +opt.magic = true -- Vim's regular expression magic +opt.mat = 2 -- How many tenths of seconds ro blink +opt.fileformats = 'unix,mac,dos' -- Unix as standard file format +opt.encoding = 'utf-8' -- Encoding +opt.viewoptions = 'folds,cursor,curdir,slash,unix' +opt.wildignorecase = true +opt.wildignore = '.git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,*.DS_Store,**/node_modules/**,**/bower_modules/**' +opt.hlsearch = false -- No highlight search +opt.incsearch = true +opt.ignorecase = true +opt.backspace = 'indent,eol,start' +opt.exrc = true + +----------------------------------------------------------- +-- Tabs, indent +----------------------------------------------------------- +opt.shiftwidth = 4 -- Shift 4 spaces when tab +opt.tabstop = 4 -- 1 tab == 4 spaces +opt.softtabstop = 4 -- 1 tab == 4 spaces +opt.expandtab = false -- Use spaces instead of tabs +opt.smartindent = true -- Autoindent new lines +opt.autoindent = true -- Copy indent from current line when starting new line +opt.cindent = true -- C programming indentation + +----------------------------------------------------------- +-- Memory, CPU +----------------------------------------------------------- +opt.hidden = true -- Enable background buffers +opt.lazyredraw = true -- Faster scrolling +opt.synmaxcol = 240 -- Max column for syntax highlight +opt.updatetime = 300 -- ms to wait for trigger an event +opt.timeoutlen = 500 -- ms to wait for a mapped sequence to complete. +opt.foldenable = false + +----------------------------------------------------------- +-- Startup +----------------------------------------------------------- +-- Disable nvim intro +opt.shortmess:append "csI" + +-- -- Disable builtin plugins +local disabled_built_ins = { + "2html_plugin", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", + "tutor", + "rplugin", + "synmenu", + "optwin", + "compiler", + "bugreport", +} + +for _, plugin in pairs(disabled_built_ins) do + g["loaded_" .. plugin] = 1 +end diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua new file mode 100644 index 0000000..e47ff11 --- /dev/null +++ b/plugin/keymaps.lua @@ -0,0 +1,61 @@ +----------------------------------------------------------- +-- Define keymaps of Neovim and installed plugins. +----------------------------------------------------------- + +local function map(mode, lhs, rhs, opts) + local options = { noremap = true, silent = true } + if opts then + options = vim.tbl_extend('force', options, opts) + end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +-- Change leader to a comma +vim.g.mapleader = ',' + +----------------------------------------------------------- +-- Neovim shortcuts +----------------------------------------------------------- + +-- Disable arrow keys +map('', '<up>', '<nop>') +map('', '<down>', '<nop>') +map('', '<left>', '<nop>') +map('', '<right>', '<nop>') + +-- Reload configuration without restart nvim +map('n', '<leader>r', ':so %<CR>') + +-- Change split orientation +map('n', '<leader>tk', '<C-w>t<C-w>K') -- change vertical to horizontal +map('n', '<leader>th', '<C-w>t<C-w>H') -- change horizontal to vertical + +map('n', 'M-j', ':resize -2<CR>') +map('n', 'M-k', ':resize +2<CR>') +map('n', 'M-l', ':vertical resize -2<CR>') +map('n', 'M-h', ':vertical resize +2<CR>') + +map('t', 'C-w', '<C-\\><C-n><C-w>') + +map('n', '<leader>B', ':Buffers<CR>') -- FZF show open buffers +map('n', '<leader>F', ':Files<CR>') -- FZF show files +map('n', '<leader>A', ':Rg<CR>') -- FZF call ripgrep +map('n', '<leader>C', ':Commits<CR>') -- FZF show git commits +map('n', '<leader>M', ':Maps<CR>') -- FZF show normal mode mappings + +map('n', '<leader>E', ':NvimTreeToggle<CR>') + +local keymap = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } +keymap("i", "<c-j>", "<cmd>lua require'luasnip'.jump(1)<CR>", opts) +keymap("s", "<c-j>", "<cmd>lua require'luasnip'.jump(1)<CR>", opts) +keymap("i", "<c-k>", "<cmd>lua require'luasnip'.jump(-1)<CR>", opts) +keymap("s", "<c-k>", "<cmd>lua require'luasnip'.jump(-1)<CR>", opts) + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float) +-- vim.keymap.set('n', '[d', vim.diagnostic.jump({count=1, float=true})) +-- vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.diagnostic.config({ jump = { float = true }}) +vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist) diff --git a/plugin/utils.lua b/plugin/utils.lua new file mode 100644 index 0000000..7c8a7bf --- /dev/null +++ b/plugin/utils.lua @@ -0,0 +1,17 @@ +-- +-- Auto group utilites +-- + +local M = {} +local cmd = vim.cmd + +function M.create_augroup(autocmds, name) + cmd('augroup ' .. name) + cmd('autocmd!') + for _, autocmd in ipairs(autocmds) do + cmd('autocmd ' .. table.concat(autocmd, ' ')) + end + cmd('augroup END') +end + +return M |