diff --git a/nvim/init.lua b/nvim/init.lua index 38b5fa7..331b636 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,24 +1,14 @@ --- Aliases -local api = vim.api -local g, b = vim.g, vim.b -local cmd = vim.cmd -local highlight = vim.highlight -local opt, opt_local = vim.opt, vim.opt_local -local go = vim.go -local map = vim.api.nvim_set_keymap -local fn = vim.fn - -g['mapleader'] = " " -g['syntax'] = true +vim.g['mapleader'] = " " +vim.g['syntax'] = true -- Bootstrapping for the package manager -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' -if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path}) +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + packer_bootstrap = vim.fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path}) end -cmd [[packadd packer.nvim]] +vim.cmd [[packadd packer.nvim]] -- Plugins require("packer").startup(function(use) if packer_bootstrap then @@ -109,7 +99,7 @@ require("packer").startup(function(use) cmp.setup({ snippet = { expand = function(args) - fn["UltiSnips#Anon"](args.body) + vim.fn["UltiSnips#Anon"](args.body) end, }, @@ -124,7 +114,7 @@ require("packer").startup(function(use) mapping = { [""] = cmp.mapping(function(fallback) if cmp.visible() then - if fn["UltiSnips#CanExpandSnippet"]() == 1 then + if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then return press("=UltiSnips#ExpandSnippet()") end @@ -157,7 +147,7 @@ require("packer").startup(function(use) }), [""] = cmp.mapping(function(fallback) - if fn["UltiSnips#CanJumpBackwards"]() == 1 then + if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then press("=UltiSnips#JumpBackwards()") elseif cmp.visible() then cmp.select_previous_item() @@ -178,6 +168,35 @@ require("packer").startup(function(use) use { "mfussenegger/nvim-dap" } use { "puremourning/vimspector" } + -- tree-sitter + use { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + config = function() + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + + require("nvim-treesitter.configs").setup({ + highlight = { + enable = true, + additional_vim_regex_highlighting = true, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + + indent = { enable = true }, + }) + end + } + -- One of the most popular plugins. -- Allows to create more substantial status bars. use { "vim-airline/vim-airline" } @@ -196,51 +215,38 @@ require("packer").startup(function(use) use { "vmchale/dhall-vim" } end) -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - -local check_back_space = function() - local col = fn.col('.') - 1 - if col == 0 or fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false - end -end - -- Editor configuration -opt.completeopt = "menuone,noselect" -opt.termguicolors = true -opt.encoding = "utf-8" -opt.number = true -opt.relativenumber = true -opt.cursorline = true -opt.expandtab = true -opt.shiftwidth = 4 -opt.tabstop = 4 -opt.conceallevel = 1 -opt.list = true -opt.listchars = { tab = " ", trail = "·" } -opt_local.spell = true -opt.smartindent = true +vim.opt.completeopt = "menuone,noselect" +vim.opt.termguicolors = true +vim.opt.encoding = "utf-8" +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.cursorline = true +vim.opt.expandtab = true +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.conceallevel = 1 +vim.opt.list = true +vim.opt.listchars = { tab = " ", trail = "·" } +vim.opt_local.spell = true +vim.opt.smartindent = true -- I have yet to solve how to do the following in Lua, lmao -cmd "highlight clear SpellBad" -cmd "highlight clear SpellLocal" -cmd "highlight clear SpellCap" -cmd "highlight clear SpellRare" -cmd "highlight CursorLineNr ctermfg=cyan" -cmd "highlight Visual term=reverse cterm=reverse" -cmd "colorscheme fds-theme" +vim.cmd "highlight clear SpellBad" +vim.cmd "highlight clear SpellLocal" +vim.cmd "highlight clear SpellCap" +vim.cmd "highlight clear SpellRare" +vim.cmd "highlight CursorLineNr ctermfg=cyan" +vim.cmd "highlight Visual term=reverse cterm=reverse" +vim.cmd "colorscheme fds-theme" -- Keybindings -map('i', 'jk', '', {}) -map('n', 'hr', 'source $MYVIMRC', {}) -map('i', "", "v:lua.tab_complete()", { expr = true }) -map('s', "", "v:lua.tab_complete()", { expr = true }) -map('i', "", "v:lua.s_tab_complete()", { expr = true }) -map('s', "", "v:lua.s_tab_complete()", { expr = true }) +vim.api.nvim_set_keymap('i', 'jk', '', {}) +vim.api.nvim_set_keymap('n', 'hr', 'source $MYVIMRC', {}) +vim.api.nvim_set_keymap('i', "", "v:lua.tab_complete()", { expr = true }) +vim.api.nvim_set_keymap('s', "", "v:lua.tab_complete()", { expr = true }) +vim.api.nvim_set_keymap('i', "", "v:lua.s_tab_complete()", { expr = true }) +vim.api.nvim_set_keymap('s', "", "v:lua.s_tab_complete()", { expr = true }) -- Activating my own modules ala-Doom Emacs. require('lsp-user-config').setup()