diff options
author | Cody Hiar <cody@hiar.ca> | 2021-09-07 19:41:44 -0600 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-09-07 19:41:44 -0600 |
commit | 9a17fc3c26a351cd5bdd20351b9ab3ff0ca2e4cb (patch) | |
tree | 973d9578b22aaf8a3e51d6d66c7df53b3946f8dc | |
parent | 7e56b36a467d44507a61c4fad0968c97fa34bb11 (diff) |
minor tweaks
-rw-r--r-- | init.lua | 73 |
1 files changed, 38 insertions, 35 deletions
@@ -1,15 +1,20 @@ --[[ -How to install +To install everything run `:PackerSync` -1. Run `PackerSync` -2. Run TSInstall <langauge> for treesitter grammar -3. LspInfo to check if the language servers are working +LspInfo to check if the language servers are working +]]-- -Todo -https://dev.to/voyeg3r/writing-useful-lua-functions-to-my-neovim-14ki -function to remove whitespace and preserve spot on save -]]-- +-- https://dev.to/voyeg3r/writing-useful-lua-functions-to-my-neovim-14ki +-- function to remove whitespace and preserve spot on save +function _G.preserve(cmd) + cmd = string.format('keepjumps keeppatterns execute %q', cmd) + local original_cursor = vim.fn.winsaveview() + vim.api.nvim_command(cmd) + vim.fn.winrestview(original_cursor) +end +vim.cmd([[autocmd BufWritePre,FileWritePre,FileAppendPre,FilterWritePre * :lua preserve('%s/\\s\\+$//ge')]]) + -- Bootstrap packer if not installed local fn = vim.fn @@ -21,16 +26,12 @@ end -local o = vim.o -local g = vim.g -local cmd = vim.cmd -local map = vim.api.nvim_set_keymap - - --- https://old.reddit.com/r/neovim/comments/lrz18i/how_to_change_colorscheme_in_lua_without_any/ -g.colors_name = "nord" -g.SuperTabDefaultCompletionType = "<c-n>" +-- https://old.reddit.com/r/neovim/comments/lrz18i/how_to_change_colorscheme_in_lua_without_any/ +vim.g.colors_name = "nord" +vim.g.SuperTabDefaultCompletionType = "<c-n>" +-- Shortcut the map function +local map = vim.api.nvim_set_keymap -- Set up spacebar as leader -- https://icyphox.sh/blog/nvim-lua/ @@ -38,18 +39,18 @@ map('n', '<Space>', '', {}) vim.g.mapleader = ' ' -- Set spaces > tabs, 4 as default -o.expandtab = true -o.tabstop = 4 -o.shiftwidth = 0 -o.relativenumber = true +vim.o.expandtab = true +vim.o.tabstop = 4 +vim.o.shiftwidth = 0 +vim.o.relativenumber = true -o.wrap = false -o.history = 1000 +vim.o.wrap = false +vim.o.history = 1000 -- Wildmode show list, complete to first result -o.wildignore = "*/app/cache,*/vendor,*/env,*.pyc,*/venv,*/__pycache__,*/venv" -o.splitright = true -o.splitbelow = true -o.spelllang = "en_ca" +vim.o.wildignore = "*/app/cache,*/vendor,*/env,*.pyc,*/venv,*/__pycache__,*/venv" +vim.o.splitright = true +vim.o.splitbelow = true +vim.o.spelllang = "en_ca" local highlights = { @@ -68,12 +69,12 @@ local highlights = { "IndentBlanklineIndent2 ctermbg=235 ctermfg=NONE", } for i, highlight in ipairs(highlights) do - cmd('au VimEnter * hi ' .. highlight) + vim.cmd('au VimEnter * hi ' .. highlight) end -- Along with the highlight definition for ColorColumn above, these options -- will set colored marks at certain line lengths -cmd [[ +vim.cmd [[ au BufEnter *.py let w:m1=matchadd('ColorColumn', '\%81v', 100) au BufEnter *.py let w:m2=matchadd('Error', '\%121v', 100) au BufLeave *.py call clearmatches() @@ -81,13 +82,15 @@ au BufLeave *.py call clearmatches() -- Custom commands -cmd [[ +vim.cmd [[ command! MakeTagsPython !ctags --exclude=venv --languages=python --python-kinds=-i -R . ]] options = { noremap = true } + + map('n', '<leader><leader>', ':noh<cr>', options) map('i', 'jj', '<esc>', options) @@ -95,8 +98,8 @@ map('i', 'jj', '<esc>', options) map('n', 'gp', "`[v`]", options) map('n', '<leader>ps', '<cmd>PackerSync<cr>', options) map('n', '<leader>ff', '<cmd>Telescope find_files<cr>', options) -map('n', '<leader>fb', '<cmd>Telescope buffers<cr>', options) -map('n', '<leader>fj', '<cmd>Telescope jumplist<cr>', options) +map('n', '<leader>fb', '<cmd>Telescope buffers<cr>', options) +map('n', '<leader>fj', '<cmd>Telescope jumplist<cr>', options) map('n', '<leader>f/', '<cmd>Telescope live_grep<cr>', options) map('n', '<leader>fa', '<cmd>Telescope grep_string<cr>', options) map('n', '<leader>fg', "<cmd>lua require('telescope.builtin').git_status()<cr>", options) @@ -192,7 +195,7 @@ local stl = { '%{&filetype}', } -o.statusline = table.concat(stl) +vim.o.statusline = table.concat(stl) return require('packer').startup(function() @@ -216,7 +219,7 @@ return require('packer').startup(function() enable = true, }, indent = { - enable = true, + enable = true, }, rainbow = { enable = true, @@ -296,7 +299,7 @@ return require('packer').startup(function() 'nvim-telescope/telescope.nvim', requires = { {'nvim-lua/plenary.nvim'}, - {'glepnir/lspsaga.nvim'}, + {'glepnir/lspsaga.nvim'}, {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, }, config = function() |