Advertisement
metalx1000

NeoVIM lua config

Feb 16th, 2023 (edited)
1,336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. local function map(m, k, v)
  2.   vim.keymap.set(m, k, v, { silent = true })
  3. end
  4.  
  5. local o = vim.opt
  6. --fix indenting with F6
  7. local function indent()
  8.   vim.g.tabstop = 2
  9.   vim.g.shiftwidth = 2
  10.   local line = vim.api.nvim_win_get_cursor(0)
  11.   vim.cmd[[
  12.   normal gg=G
  13.   ]]
  14.   vim.api.nvim_win_set_cursor(0,line)
  15. end
  16. map("n","<F5>", indent)
  17.  
  18. --remember the last line you where on in a while at open
  19. vim.cmd[[
  20. if has("autocmd")
  21. au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  22. endif
  23. ]]
  24.  
  25.  
  26. --quit commands
  27. vim.cmd[[
  28. command! Wq :wq
  29. command! W :w
  30. command! Q :q
  31. :cmap Q! q!
  32. :cmap q1 q!
  33. ]]
  34. --run template search
  35. map("i", "<C-t>", "<ESC>:read !$HOME/.vim/vim_templates.sh<CR>mqgg=G'qzzi")
  36.  
  37. --load templates
  38. map("n", "<leader>html", ":-1read $HOME/.vim/skeleton/html/index.html<CR>3j2f<i")
  39. map("n", "<leader>bash", ":-1read $HOME/.vim/skeleton/sh/bash_header.sh<CR>Gi")
  40.  
  41. --show relative line number
  42. vim.o.relativenumber = true
  43.  
  44.  
  45. --load default templates on new files
  46. vim.cmd[[autocmd BufNewFile  *.html 0r ~/.vim/skeleton/html/index.html]]
  47. vim.cmd[[autocmd BufNewFile  *.sh 0r ~/.vim/skeleton/sh/bash_header.sh]]
  48. --local x = require('telescope.builtin').find_files(require('telescope.actions.state').get_selected_entry())
  49. --print(x)
  50. o.expandtab = true
  51. o.tabstop=2
  52. o.shiftwidth=2
  53. o.hlsearch = true
  54. o.incsearch = true
  55. o.scrolloff = 10
  56.  
  57. --move selected lines up and down when in Visual Mode
  58. map("v","J",":m '>+1<CR>gv=gv")
  59. map("v","K",":m '<-2<CR>gv=gv")
  60.  
  61. --keep cursor centered while searching
  62. map("n","n","nzzzv")
  63. map("n","N","Nzzzv")
  64.  
  65. --yank/copy into system clipboard
  66. map("v", "<leader>y", "\"+y")
  67. map("n", "<leader>y", "\"+y")
  68.  
  69. --replace every instance of current word
  70. map("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
  71.  
  72. --make current file executable
  73. map("n", "<leader>x", "<cmd>!chmod +x %<CR>")
  74.  
  75. map('n', '<leader>fs', '<cmd>lua require("telescope.builtin").find_files()<CR>', opts)
  76. map('n', '<leader>ff', '<cmd>lua require("telescope.builtin").find_files()<CR>', opts)
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement