From 0b5f3fc96eddcd603de17644da8a962e0a93c04a Mon Sep 17 00:00:00 2001 From: Brahmajit Das Date: Sun, 29 Dec 2024 13:55:26 +0530 Subject: moving global settings to plugin folder, for autoloading Signed-off-by: Brahmajit Das --- lua/appearance.lua | 53 ------------------------------ lua/basics.lua | 89 --------------------------------------------------- lua/keymaps.lua | 61 ----------------------------------- lua/utils.lua | 17 ---------- plugin/appearance.lua | 53 ++++++++++++++++++++++++++++++ plugin/basics.lua | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ plugin/keymaps.lua | 61 +++++++++++++++++++++++++++++++++++ plugin/utils.lua | 17 ++++++++++ 8 files changed, 220 insertions(+), 220 deletions(-) delete mode 100644 lua/appearance.lua delete mode 100644 lua/basics.lua delete mode 100644 lua/keymaps.lua delete mode 100644 lua/utils.lua create mode 100644 plugin/appearance.lua create mode 100644 plugin/basics.lua create mode 100644 plugin/keymaps.lua create mode 100644 plugin/utils.lua diff --git a/lua/appearance.lua b/lua/appearance.lua deleted file mode 100644 index 3151523..0000000 --- a/lua/appearance.lua +++ /dev/null @@ -1,53 +0,0 @@ -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/lua/basics.lua b/lua/basics.lua deleted file mode 100644 index 66e53fa..0000000 --- a/lua/basics.lua +++ /dev/null @@ -1,89 +0,0 @@ ------------------------------------------------------------ --- 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/lua/keymaps.lua b/lua/keymaps.lua deleted file mode 100644 index e47ff11..0000000 --- a/lua/keymaps.lua +++ /dev/null @@ -1,61 +0,0 @@ ------------------------------------------------------------ --- 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('', '', '') -map('', '', '') -map('', '', '') -map('', '', '') - --- Reload configuration without restart nvim -map('n', 'r', ':so %') - --- Change split orientation -map('n', 'tk', 'tK') -- change vertical to horizontal -map('n', 'th', 'tH') -- change horizontal to vertical - -map('n', 'M-j', ':resize -2') -map('n', 'M-k', ':resize +2') -map('n', 'M-l', ':vertical resize -2') -map('n', 'M-h', ':vertical resize +2') - -map('t', 'C-w', '') - -map('n', 'B', ':Buffers') -- FZF show open buffers -map('n', 'F', ':Files') -- FZF show files -map('n', 'A', ':Rg') -- FZF call ripgrep -map('n', 'C', ':Commits') -- FZF show git commits -map('n', 'M', ':Maps') -- FZF show normal mode mappings - -map('n', 'E', ':NvimTreeToggle') - -local keymap = vim.api.nvim_set_keymap -local opts = { noremap = true, silent = true } -keymap("i", "", "lua require'luasnip'.jump(1)", opts) -keymap("s", "", "lua require'luasnip'.jump(1)", opts) -keymap("i", "", "lua require'luasnip'.jump(-1)", opts) -keymap("s", "", "lua require'luasnip'.jump(-1)", opts) - --- Global mappings. --- See `:help vim.diagnostic.*` for documentation on any of the below functions -vim.keymap.set('n', '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', 'q', vim.diagnostic.setloclist) diff --git a/lua/utils.lua b/lua/utils.lua deleted file mode 100644 index 7c8a7bf..0000000 --- a/lua/utils.lua +++ /dev/null @@ -1,17 +0,0 @@ --- --- 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 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('', '', '') +map('', '', '') +map('', '', '') +map('', '', '') + +-- Reload configuration without restart nvim +map('n', 'r', ':so %') + +-- Change split orientation +map('n', 'tk', 'tK') -- change vertical to horizontal +map('n', 'th', 'tH') -- change horizontal to vertical + +map('n', 'M-j', ':resize -2') +map('n', 'M-k', ':resize +2') +map('n', 'M-l', ':vertical resize -2') +map('n', 'M-h', ':vertical resize +2') + +map('t', 'C-w', '') + +map('n', 'B', ':Buffers') -- FZF show open buffers +map('n', 'F', ':Files') -- FZF show files +map('n', 'A', ':Rg') -- FZF call ripgrep +map('n', 'C', ':Commits') -- FZF show git commits +map('n', 'M', ':Maps') -- FZF show normal mode mappings + +map('n', 'E', ':NvimTreeToggle') + +local keymap = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } +keymap("i", "", "lua require'luasnip'.jump(1)", opts) +keymap("s", "", "lua require'luasnip'.jump(1)", opts) +keymap("i", "", "lua require'luasnip'.jump(-1)", opts) +keymap("s", "", "lua require'luasnip'.jump(-1)", opts) + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', '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', '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 -- cgit v1.2.3