CCCPaste

NeoVIM lua config

local function map(m, k, v)
  vim.keymap.set(m, k, v, { silent = true })
end

local o = vim.opt
--fix indenting with F6
local function indent()
  vim.g.tabstop = 2
  vim.g.shiftwidth = 2
  local line = vim.api.nvim_win_get_cursor(0)
  vim.cmd[[ 
  normal gg=G
  ]]
  vim.api.nvim_win_set_cursor(0,line)
end
map("n","", indent)

--remember the last line you where on in a while at open
vim.cmd[[
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
]]


--quit commands
vim.cmd[[
command! Wq :wq
command! W :w
command! Q :q
:cmap Q! q!
:cmap q1 q!
]]
--run template search
map("i", "", ":read !$HOME/.vim/vim_templates.shmqgg=G'qzzi")

--load templates
map("n", "html", ":-1read $HOME/.vim/skeleton/html/index.html3j2fbash", ":-1read $HOME/.vim/skeleton/sh/bash_header.shGi")

--show relative line number
vim.o.relativenumber = true


--load default templates on new files
vim.cmd[[autocmd BufNewFile  *.html 0r ~/.vim/skeleton/html/index.html]]
vim.cmd[[autocmd BufNewFile  *.sh 0r ~/.vim/skeleton/sh/bash_header.sh]]
--local x = require('telescope.builtin').find_files(require('telescope.actions.state').get_selected_entry())
--print(x)
o.expandtab = true
o.tabstop=2
o.shiftwidth=2
o.hlsearch = true 
o.incsearch = true
o.scrolloff = 10

--move selected lines up and down when in Visual Mode
map("v","J",":m '>+1gv=gv")
map("v","K",":m '<-2gv=gv")

--keep cursor centered while searching
map("n","n","nzzzv")
map("n","N","Nzzzv")

--yank/copy into system clipboard
map("v", "y", "\"+y")
map("n", "y", "\"+y")

--replace every instance of current word
map("n", "s", [[:%s/\<\>//gI]])

--make current file executable
map("n", "x", "!chmod +x %")

map('n', 'fs', 'lua require("telescope.builtin").find_files()', opts)
map('n', 'ff', 'lua require("telescope.builtin").find_files()', opts)