From 841751ff3031fbb0752c6bf48821b63ed5b64dd3 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Fri, 16 Sep 2022 01:50:38 +0300 Subject: [PATCH] add more configs - add basic.lua - plugin/explorer: add nvim-tree plugin - plugin/theme: add catppuccin-nvim plugin - plugin/syntax: add more grammars --- basic.lua | 210 ++++++++++++++++++++++++++++++++++++++ default.nix | 12 ++- explorer/default.nix | 9 ++ explorer/nvim-tree.lua | 12 +++ syntax/default.nix | 13 ++- theme/catppuccin-nvim.lua | 5 + theme/default.nix | 7 ++ 7 files changed, 263 insertions(+), 5 deletions(-) create mode 100644 basic.lua create mode 100644 explorer/default.nix create mode 100644 explorer/nvim-tree.lua create mode 100644 theme/catppuccin-nvim.lua create mode 100644 theme/default.nix diff --git a/basic.lua b/basic.lua new file mode 100644 index 0000000..265a8b9 --- /dev/null +++ b/basic.lua @@ -0,0 +1,210 @@ +------------------------------------------------------------------------------- +-- +-- Basic Settings +-- + +vim.cmd("filetype off") + +-- Leaders +vim.g.mapleader = "," +vim.g.maplocalleader = "-" + +-- Better Unix support +vim.opt.viewoptions = { "folds", "options", "cursor", "unix", "slash" } +vim.opt.encoding = "utf-8" + +-- True color support +vim.opt.termguicolors = true + +-- Theme (required plugin 'material-vim') +-- Available styles: default, planight, ocean, lighter +-- darker, default-community, palenight-community, ocean-community, +-- lighter-community, darker-community +-- vim.g.material_theme_style = "default" +-- vim.g.lightline = { colorscheme = "material_vim" } +-- vim.cmd("colorscheme material") + +-- Other options +vim.cmd("syntax on") +vim.opt.backspace = { "indent", "eol", "start" } +vim.opt.laststatus = 2 +vim.opt.showmode = false + +-- Tabs as spaces +vim.opt.expandtab = true +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 + +-- Fixes broken cursor on Linux +vim.opt.guicursor = "" + +-- Disable mouse / touchpad +vim.opt.mouse = "" + +-- Incremental substitutin +vim.opt.inccommand = "split" + +------------------------------------------------------------------------------- +-- +-- General editor options +-- + +-- Hide files when leaving them. +vim.opt.hidden = true +-- Show line numbers. +vim.opt.number = true +-- Minimum line number column width. +vim.opt.numberwidth = 1 +-- Number of screen lines to use for the commandline. +vim.opt.cmdheight = 2 +-- Lines length limit (0 if no limit). +vim.opt.textwidth = 0 +-- Don't cut lines in the middle of a work. +vim.opt.linebreak = true +-- Show matching parenthesis. +vim.opt.showmatch = true +-- Time during which the matching parenthesis is shown. +vim.opt.matchtime = 2 +-- Sensible default line auto cutting and formatting. +vim.opt.formatoptions = "jtcrq" +-- Copy/Past to/from clipboard. +vim.opt.clipboard = "unnamedplus" +-- Highlight line cursor is currently on. +vim.opt.cursorline = true +-- Invisible characters representation when :set list +vim.opt.listchars = { + tab = "→ ", + trail = "~", + nbsp = "␣", + eol = "¬", +} + +-- Search +-- Incremental search. +vim.opt.incsearch = true +-- Case insensitive. +vim.opt.ignorecase = true +-- Case insensitive if no uppercase letter in pattern, case sensitive otherwise. +vim.opt.smartcase = true + +-- Spell +vim.opt.spelllang = "en,ru" + +-- Fold level +vim.opt.foldlevel = 99 +vim.opt.foldlevelstart = 99 +vim.opt.foldminlines = 3 +vim.opt.foldnestmax = 5 + +------------------------------------------------------------------------------- +-- +-- File type specified +-- +local bufReadFile = { "BufNewFile", "BufRead" } + +-- Set up a line limiter for each lang +local line_limiter_augroup = vim.api.nvim_create_augroup("line_limiter", {}) +local function set_line_limiter(limit, patterns) + vim.api.nvim_create_autocmd(bufReadFile, { + pattern = patterns, + group = line_limiter_augroup, + callback = function() + vim.wo.colorcolumn = tostring(limit) + end, + }) +end + +set_line_limiter(101, { + "*.nix", + "*.vim", + "*.lua", + "*.ts", + "*.tsx", + "*.js", + "*.jsx", + "*.rs", +}) +set_line_limiter(81, { + "*.json", + "*.yml", + "*.yaml", + "*.md", + "*.html", + "*.css", +}) + +-- Spell check for markdown files +local spell_check_augroup = vim.api.nvim_create_augroup("spell_check", {}) +vim.api.nvim_create_autocmd(bufReadFile, { + pattern = { "*.md" }, + group = spell_check_augroup, + callback = function() + vim.wo.spell = true + end, +}) + +-- Set up fold method for each lang +local folding_augroup = vim.api.nvim_create_augroup("folding", {}) +vim.api.nvim_create_autocmd(bufReadFile, { + group = folding_augroup, + pattern = { + "*.js", + "*.jsx", + "*.ts", + "*.tsx", + }, + callback = function() + vim.cmd("syntax on") + vim.wo.foldmethod = "syntax" + end, +}) + +------------------------------------------------------------------------------- +-- +-- Bindings +-- +local function clear_search_hl() + vim.opt.hlsearch = false +end +vim.keymap.set("n", "", clear_search_hl, { desc = "Clear search highlighting" }) + +-- Enable fast navigation between windows +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "l") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") + +-- Disable the annoying and useless ex-mode +vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "gQ", "") + +-- Disable arrow keys +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("v", "", "") +vim.keymap.set("v", "", "") +vim.keymap.set("v", "", "") +vim.keymap.set("v", "", "") +-- ... instead of insert mode for rus lang and popups +-- vim.keymap.set("i", "", "") +-- vim.keymap.set("i", "", "") +-- vim.keymap.set("i", "", "") +-- vim.keymap.set("i", "", "") + +-- Disable page up / down +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("v", "", "") +vim.keymap.set("v", "", "") +vim.keymap.set("i", "", "") +vim.keymap.set("i", "", "") + +------------------------------------------------------------------------------- +-- +-- Abbreviatures +-- +vim.cmd("cabbrev bsp belowright split") +vim.cmd("cabbrev rvsp belowright vsplit") diff --git a/default.nix b/default.nix index 0eab4b2..e5f9ba0 100644 --- a/default.nix +++ b/default.nix @@ -3,10 +3,16 @@ let lib = import ./lib.nix; - plugins = [ - (callPackage ./syntax { }) + callPlugins = list: builtins.map (p: callPackage p { }) list; + + plugins = callPlugins [ + ./syntax + ./explorer + ./theme ]; + basicConfig = builtins.readFile ./basic.lua; + in wrapNeovim neovim-unwrapped { withPython3 = false; @@ -14,7 +20,7 @@ wrapNeovim neovim-unwrapped { withRuby = false; configure = { - customRC = lib.mkLuaRc (lib.extractAttrs "luaConfig" plugins); + customRC = lib.mkLuaRc ([ basicConfig ] ++ lib.extractAttrs "luaConfig" plugins); packages.myVimPackages = { start = lib.extractAttrs "plugins" plugins; }; diff --git a/explorer/default.nix b/explorer/default.nix new file mode 100644 index 0000000..c3afe17 --- /dev/null +++ b/explorer/default.nix @@ -0,0 +1,9 @@ +{ vimPlugins, ... }: + +{ + luaConfig = builtins.readFile ./nvim-tree.lua; + + plugins = [ + vimPlugins.nvim-tree-lua + ]; +} diff --git a/explorer/nvim-tree.lua b/explorer/nvim-tree.lua new file mode 100644 index 0000000..bd1ebef --- /dev/null +++ b/explorer/nvim-tree.lua @@ -0,0 +1,12 @@ +-- See: https://github.com/kyazdani42/nvim-tree.lua/blob/master/doc/nvim-tree-lua.txt + +-- disable netrw at the very start of your init.lua (strongly advised) +vim.g.loaded = 1 +vim.g.loaded_netrwPlugin = 1 + +-- empty setup using defaults +require("nvim-tree").setup() + +vim.keymap.set("n", "nt", ":NvimTreeFocus") +vim.keymap.set("n", "nf", ":NvimTreeFindFile") + diff --git a/syntax/default.nix b/syntax/default.nix index 65fb716..195ba99 100644 --- a/syntax/default.nix +++ b/syntax/default.nix @@ -5,8 +5,17 @@ plugins = [ (vimPlugins.nvim-treesitter.withPlugins - (ts: [ - ts.tree-sitter-nix + (ts: with ts; [ + tree-sitter-nix + tree-sitter-lua + tree-sitter-ledger + tree-sitter-yaml + tree-sitter-json + tree-sitter-typescript + tree-sitter-javascript + tree-sitter-rust + tree-sitter-haskell + tree-sitter-bash ])) ]; } diff --git a/theme/catppuccin-nvim.lua b/theme/catppuccin-nvim.lua new file mode 100644 index 0000000..014497a --- /dev/null +++ b/theme/catppuccin-nvim.lua @@ -0,0 +1,5 @@ +vim.g.catppuccin_flavour = "frappe" -- latte, frappe, macchiato, mocha + +require("catppuccin").setup() + +vim.cmd [[colorscheme catppuccin]] diff --git a/theme/default.nix b/theme/default.nix new file mode 100644 index 0000000..0804262 --- /dev/null +++ b/theme/default.nix @@ -0,0 +1,7 @@ +{ vimPlugins, ... }: + +{ + luaConfig = builtins.readFile ./catppuccin-nvim.lua; + + plugins = [ vimPlugins.catppuccin-nvim ]; +}