Guest User

Untitled

a guest
Sep 7th, 2022
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.91 KB | None | 0 0
  1. function map(mode, lhs, rhs, opts)
  2. local options = { noremap = true, silent = false }
  3. if opts then
  4. options = vim.tbl_extend("force", options, opts)
  5. end
  6. vim.api.nvim_set_keymap(mode, lhs, rhs, options)
  7. end
  8.  
  9. vim.g.mapleader = " "
  10.  
  11. local fn = vim.fn
  12. local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
  13. if fn.empty(fn.glob(install_path)) > 0 then
  14. packer_bootstrap = fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim',
  15. install_path })
  16. vim.cmd [[packadd packer.nvim]]
  17. end
  18.  
  19. require('packer').startup(function(use)
  20.  
  21. use { "wbthomason/packer.nvim" }
  22.  
  23. use 'machakann/vim-highlightedyank'
  24. use 'aklt/plantuml-syntax'
  25. use 'tpope/vim-repeat'
  26. use 'tpope/vim-surround'
  27. use 'habamax/vim-asciidoctor'
  28. use 'dag/vim-fish'
  29. use 'dstein64/vim-startuptime'
  30. use 'lordm/vim-browser-reload-linux'
  31. use 'stevearc/dressing.nvim'
  32. use {
  33. 'RRethy/vim-hexokinase',
  34. run = 'make hexokinase',
  35. }
  36.  
  37. use 'numToStr/Comment.nvim'
  38.  
  39. require('Comment').setup({})
  40.  
  41. local opt = { expr = true, remap = true, replace_keycodes = false }
  42. vim.keymap.set('n', '<leader>c',
  43. "v:count == 0 ? '<Plug>(comment_toggle_linewise_current)' : '<Plug>(comment_toggle_linewise_count)'", opt)
  44. vim.keymap.set('x', '<leader>c', '<Plug>(comment_toggle_linewise_visual)')
  45.  
  46. use 'ethanholz/nvim-lastplace'
  47.  
  48. require 'nvim-lastplace'.setup {
  49. lastplace_ignore_buftype = { "quickfix", "nofile", "help" },
  50. lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" },
  51. lastplace_open_folds = true
  52. }
  53.  
  54. use 'Mofiqul/dracula.nvim'
  55. -- vim.opt.colorscheme = "dracula"
  56. vim.cmd[[colorscheme dracula]]
  57.  
  58. use 'neovim/nvim-lspconfig'
  59.  
  60. require 'lspconfig'.vimls.setup {}
  61. require 'lspconfig'.yamlls.setup {}
  62. require 'lspconfig'.bashls.setup {}
  63. require 'lspconfig'.dockerls.setup {}
  64. require 'lspconfig'.eslint.setup {}
  65. require 'lspconfig'.stylelint_lsp.setup {}
  66. require 'lspconfig'.cmake.setup {}
  67. require 'lspconfig'.clangd.setup {}
  68. require 'lspconfig'.zk.setup {}
  69. require 'lspconfig'.pylsp.setup {}
  70. require 'lspconfig'.sumneko_lua.setup {}
  71. require 'lspconfig'.taplo.setup {}
  72. -- require 'lspconfig'.jsonnet_ls.setup {}
  73. --
  74. local capabilities = vim.lsp.protocol.make_client_capabilities()
  75. capabilities.textDocument.completion.completionItem.snippetSupport = true
  76. require 'lspconfig'.jsonls.setup {
  77. capabilities = capabilities,
  78. }
  79.  
  80. map("n", "<leader>d", ":lua vim.lsp.buf.definition()<CR>");
  81. map("n", "<leader>a", ":lua vim.lsp.buf.code_action()<CR>");
  82. map("n", "<leader>i", ":lua vim.lsp.buf.implementation()<CR>");
  83. -- map("n", "<leader>c", ":lua vim.lsp.buf.incoming_calls()<CR>");
  84. map("n", "<leader>f", ":lua vim.lsp.buf.formatting_seq_sync()<CR>");
  85. map("n", "<leader>h", ":lua vim.lsp.buf.hover()<CR>");
  86. map("n", "<leader>r", ":lua vim.lsp.buf.rename()<CR>");
  87. map("v", "<leader>r", ":lua vim.lsp.buf.range_code_action()<CR>");
  88.  
  89. vim.api.nvim_create_autocmd({ "CursorHold", "InsertLeave" },
  90. { pattern = "*.*", command = ":lua vim.lsp.codelens.refresh()" })
  91. vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.*", command = ":lua vim.lsp.buf.formatting_sync()" })
  92.  
  93. use 'yamatsum/nvim-cursorline'
  94.  
  95. require('nvim-cursorline').setup {
  96. cursorline = {
  97. enable = true,
  98. timeout = 1000,
  99. number = false,
  100. },
  101. cursorword = {
  102. enable = true,
  103. min_length = 3,
  104. hl = { underline = true },
  105. }
  106. }
  107.  
  108. use 'lnl7/vim-nix'
  109.  
  110. require 'lspconfig'.rnix.setup {}
  111.  
  112. use "lukas-reineke/indent-blankline.nvim"
  113.  
  114. require("indent_blankline").setup {
  115. space_char_blankline = " ",
  116. show_current_context = true,
  117. show_current_context_start = true,
  118. -- indent_blankline_filetype_exclude = ["org"],
  119. }
  120.  
  121. vim.cmd("let g:indent_blankline_filetype_exclude = ['org']")
  122.  
  123. -- use "tpope/vim-sleuth"
  124.  
  125. use 'lewis6991/gitsigns.nvim'
  126.  
  127. require('gitsigns').setup()
  128.  
  129. use {
  130. "folke/trouble.nvim",
  131. requires = "kyazdani42/nvim-web-devicons",
  132. config = function()
  133. require("trouble").setup {}
  134. end
  135. }
  136.  
  137. use { 'nvim-lualine/lualine.nvim',
  138. requires = { 'kyazdani42/nvim-web-devicons', opt = true } }
  139.  
  140. require 'nvim-web-devicons'.setup {
  141. default = true;
  142. }
  143. require('lualine').setup {
  144. options = {
  145. theme = 'dracula'
  146. }
  147. }
  148.  
  149. use 'derekwyatt/vim-fswitch'
  150.  
  151. map("n", "<Leader>s", ":FSHere<CR>")
  152.  
  153. use 'hrsh7th/nvim-cmp'
  154. use 'hrsh7th/cmp-nvim-lsp'
  155. use 'f3fora/cmp-spell'
  156. use 'hrsh7th/cmp-buffer'
  157. use 'hrsh7th/cmp-path'
  158. use 'hrsh7th/cmp-cmdline'
  159. use 'hrsh7th/cmp-git'
  160. use 'hrsh7th/cmp-vsnip'
  161. use 'hrsh7th/vim-vsnip'
  162. use 'hrsh7th/vim-vsnip-integ'
  163. use 'rafamadriz/friendly-snippets'
  164.  
  165. vim.opt.completeopt = { "menu", "menuone", "noselect" }
  166.  
  167. local cmp = require 'cmp'
  168. cmp.setup({
  169. snippet = {
  170. -- REQUIRED - you must specify a snippet engine
  171. expand = function(args)
  172. vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
  173. -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
  174. -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
  175. -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
  176. end,
  177. },
  178. window = {
  179. -- completion = cmp.config.window.bordered(),
  180. -- documentation = cmp.config.window.bordered(),
  181. },
  182. mapping = cmp.mapping.preset.insert({
  183. ['<C-b>'] = cmp.mapping.scroll_docs(-4),
  184. ['<C-f>'] = cmp.mapping.scroll_docs(4),
  185. ['<C-Space>'] = cmp.mapping.complete(),
  186. ['<C-e>'] = cmp.mapping.abort(),
  187. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
  188. }),
  189. sources = cmp.config.sources({
  190. { name = 'nvim_lsp' },
  191. { name = 'orgmode' },
  192. { name = 'spell' },
  193. { name = 'vsnip' }, -- For vsnip users.
  194. -- { name = 'luasnip' }, -- For luasnip users.
  195. -- { name = 'ultisnips' }, -- For ultisnips users.
  196. -- { name = 'snippy' }, -- For snippy users.
  197. }, {
  198. { name = 'buffer' },
  199. })
  200. })
  201. -- Set configuration for specific filetype.
  202. cmp.setup.filetype('gitcommit', {
  203. sources = cmp.config.sources({
  204. { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
  205. }, {
  206. { name = 'buffer' },
  207. })
  208. })
  209.  
  210. -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
  211. cmp.setup.cmdline('/', {
  212. mapping = cmp.mapping.preset.cmdline(),
  213. sources = {
  214. { name = 'buffer' }
  215. }
  216. })
  217.  
  218. -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  219. cmp.setup.cmdline(':', {
  220. mapping = cmp.mapping.preset.cmdline(),
  221. sources = cmp.config.sources({
  222. { name = 'path' }
  223. }, {
  224. { name = 'cmdline' }
  225. })
  226. })
  227.  
  228. -- Setup lspconfig.
  229. local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
  230. -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
  231. require('lspconfig')['rnix'].setup {
  232. capabilities = capabilities
  233. }
  234. require('lspconfig')['vimls'].setup {
  235. capabilities = capabilities
  236. }
  237. require('lspconfig')['rust_analyzer'].setup {
  238. capabilities = capabilities
  239. }
  240. require('lspconfig')['bashls'].setup {
  241. capabilities = capabilities
  242. }
  243. require('lspconfig')['dockerls'].setup {
  244. capabilities = capabilities
  245. }
  246. require('lspconfig')['eslint'].setup {
  247. capabilities = capabilities
  248. }
  249. require('lspconfig')['stylelint_lsp'].setup {
  250. capabilities = capabilities
  251. }
  252. require('lspconfig')['cmake'].setup {
  253. capabilities = capabilities
  254. }
  255. require('lspconfig')['clangd'].setup {
  256. capabilities = capabilities
  257. }
  258. require('lspconfig')['zk'].setup {
  259. capabilities = capabilities
  260. }
  261. require('lspconfig')['pylsp'].setup {
  262. capabilities = capabilities
  263. }
  264. require('lspconfig')['sumneko_lua'].setup {
  265. capabilities = capabilities
  266. }
  267.  
  268. require'lspconfig'.hls.setup{}
  269.  
  270. use 'rust-lang/rust.vim'
  271. use 'simrat39/rust-tools.nvim'
  272.  
  273. require 'lspconfig'.rust_analyzer.setup {}
  274. require 'rust-tools'.setup()
  275.  
  276. use 'nvim-telescope/telescope.nvim'
  277. use 'nvim-lua/plenary.nvim'
  278.  
  279. use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
  280. require('telescope').load_extension('fzf')
  281.  
  282. use {
  283. 'nvim-treesitter/nvim-treesitter',
  284. run = ':TSUpdate',
  285. }
  286.  
  287. require 'nvim-treesitter.configs'.setup {
  288. ensure_installed = {
  289. "all"
  290. },
  291. auto_install = true,
  292. highlight = {
  293. enable = true,
  294. additional_vim_regex_highlighting = { 'org' },
  295. },
  296. ensure_installed = { 'org' },
  297. }
  298.  
  299. use 'nvim-orgmode/orgmode'
  300. -- use {
  301. -- 'lukas-reineke/headlines.nvim',
  302. -- config = function()
  303. -- require('headlines').setup()
  304. -- end,
  305. -- }
  306. use 'dhruvasagar/vim-table-mode'
  307. use {
  308. 'michaelb/sniprun',
  309. run = 'bash install.sh',
  310. }
  311. use 'rcarriga/nvim-notify'
  312.  
  313. require('orgmode').setup_ts_grammar()
  314. require('orgmode').setup({
  315. -- org_agenda_files = { '~/Dropbox/org/*', '~/my-orgs/**/*' },
  316. -- org_default_notes_file = '~/Dropbox/org/refile.org',
  317. })
  318.  
  319. -- for i = 1, 40, 1 do
  320. -- vim.cmd(string.format("highlight OrgHeadlineLevel%d guibg=NONE", i))
  321. -- end
  322.  
  323. use {
  324. 'akinsho/org-bullets.nvim', config = function()
  325. require('org-bullets').setup()
  326. end
  327. }
  328.  
  329. vim.opt.conceallevel = 2
  330. vim.opt.concealcursor = 'nc'
  331.  
  332. vim.api.nvim_create_autocmd("BufWritePost", { pattern = "*.org", command = "!~/tangle.py %" })
  333. vim.api.nvim_create_autocmd("BufWritePost",
  334. { pattern = "configuration.org", command = "!sudo cp ~/configuration.nix /etc/nixos/configuration.nix" })
  335. vim.api.nvim_create_autocmd("BufWritePost",
  336. { pattern = "configuration.org",
  337. command = "!cp ~/configuration.nix ~/repos/dotfiles/ && cd ~/repos/dotfiles/ && git add . && git commit -m \"Automatic configuration.nix back up\" && git push" })
  338. vim.api.nvim_create_autocmd("BufWritePost",
  339. { pattern = "configuration.org",
  340. command = "!cp ~/configuration.org ~/repos/dotfiles/ && cd ~/repos/dotfiles/ && git add . && git commit -m \"Automatic configuration.nix back up\" && git push" })
  341.  
  342. use { 'kamykn/spelunker.vim' }
  343. use { 'kamykn/popup-menu.nvim' }
  344.  
  345. use {
  346. 'kyazdani42/nvim-tree.lua',
  347. requires = {
  348. 'kyazdani42/nvim-web-devicons'
  349. }
  350. }
  351.  
  352. require 'nvim-web-devicons'.setup {
  353. default = true;
  354. }
  355.  
  356. require("nvim-tree").setup({
  357. git = {
  358. ignore = false,
  359. },
  360. actions = {
  361. open_file = {
  362. resize_window = true
  363. }
  364. }
  365. })
  366.  
  367. vim.o.splitright = true;
  368.  
  369. -- use 'nvim-treesitter/nvim-treesitter-textobjects'
  370.  
  371. use 'jeffkreeftmeijer/vim-numbertoggle'
  372.  
  373. map("n", ",t", "i#[test]<CR>fn () {<CR>}<ESC>kwi")
  374. map("n", ",tm", "i#[cfg(test)]<CR>mod tests {<CR>use super::*;<CR><CR>#[test]<CR>fn () {<CR>}<CR><ESC>xxxxi}<ESC>kkwwi")
  375.  
  376. map("n", "<Up>", "<Nop>")
  377. map("n", "<Down>", "<Nop>")
  378. map("n", "<Left>", "<Nop>")
  379. map("n", "<Right>", "<Nop>")
  380. map("i", "<Up>", "<Nop>")
  381. map("i", "<Down>", "<Nop>")
  382. map("i", "<Left>", "<Nop>")
  383. map("i", "<Right>", "<Nop>")
  384. map("v", "<Up>", "<Nop>")
  385. map("v", "<Down>", "<Nop>")
  386. map("v", "<Left>", "<Nop>")
  387. map("v", "<Right>", "<Nop>")
  388.  
  389. map("n", "j", "gj")
  390. map("n", "k", "gk")
  391.  
  392. map("n", "<leader><space>", ":noh<cr>")
  393.  
  394. map("n", ":", ";")
  395. map("n", ";", ":")
  396.  
  397. map("n", "<C-s>", ":wa<CR>")
  398.  
  399. map("n", "<Enter>", "o<ESC>")
  400. map("n", "<S-Enter>", "O<ESC>")
  401.  
  402. vim.api.nvim_create_autocmd("FocusLost", { pattern = "*.*", command = ":wa" })
  403.  
  404. vim.o.autoread = true
  405.  
  406. vim.api.nvim_create_autocmd({ "bufenter", "cursorhold", "cursorholdi", "focusgained" },
  407. { pattern = "*.*", command = "if mode() != 'c' | checktime | endif", })
  408. vim.api.nvim_create_autocmd("FileChangedShellPost",
  409. { pattern = "*.*", command = "echohl WarningMsg | echo \"File changed on disk. Buffer reloaded.\" | echohl None", })
  410.  
  411. vim.o.cursorline = true
  412.  
  413. vim.o.mouse = "a"
  414. vim.o.undofile = true
  415. vim.o.undodir = "~/.config/nvim"
  416. vim.cmd [[set noswapfile]]
  417. -- vim.opt.noswapfile = true
  418. vim.o.foldmethod = "marker"
  419. vim.o.hlsearch = true
  420. vim.o.ignorecase = true
  421. vim.o.smartcase = true
  422. vim.o.incsearch = true
  423. vim.o.showmatch = true
  424. vim.o.gdefault = true
  425. vim.o.termguicolors = true
  426. vim.o.clipboard = "unnamedplus"
  427. vim.o.tabstop = 4
  428. vim.o.shiftwidth = 4
  429. vim.o.expandtab = true
  430. vim.o.number = true
  431. vim.o.relativenumber = true
  432. vim.o.hidden = true
  433. vim.opt.spell = true
  434. vim.opt.spelllang = { 'en_us' }
  435. vim.o.spellcapcheck = "="
  436. vim.o.spellsuggest = "10"
  437. vim.opt.spelloptions = "camel"
  438. vim.o.confirm = true
  439. vim.o.wrap = false
  440. vim.opt.path = vim.opt.path + "**"
  441. vim.opt.wildmenu = true
  442.  
  443. vim.api.nvim_create_autocmd("BufWritePost",
  444. { pattern = "init.lua", command = "so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif", })
  445.  
  446. vim.cmd [[
  447. if &shell =~# 'fish$'
  448. set shell=bash
  449. endif
  450. ]]
  451.  
  452. -- autocmd QuickFixCmdPost [^l]* nested cwindow
  453. -- autocmd QuickFixCmdPost l* nested lwindow
  454. vim.api.nvim_create_autocmd("QuickFixCmdPost", { pattern = "[^l]*", command = "cwindow", })
  455. vim.api.nvim_create_autocmd("QuickFixCmdPost", { pattern = "l*", command = "lwindow", })
  456.  
  457. -- au FileType qf call AdjustWindowHeight(3, 10)
  458. -- function! AdjustWindowHeight(minheight, maxheight)
  459. -- exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
  460. -- endfunction "
  461. vim.cmd([[
  462. au FileType qf call AdjustWindowHeight(3, 10)
  463. function! AdjustWindowHeight(minheight, maxheight)
  464. exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
  465. endfunction "
  466. ]])
  467.  
  468. local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
  469. vim.api.nvim_create_autocmd('BufWritePost', {
  470. command = 'source <afile> | PackerCompile',
  471. group = packer_group,
  472. pattern = vim.fn.expand '$MYVIMRC',
  473. })
  474.  
  475. vim.api.nvim_create_autocmd("VimEnter",
  476. { pattern = "*/home/refaelsh/repos/*", command = "so .nvimrc", })
  477.  
  478. if packer_bootstrap then
  479. require('packer').sync()
  480. end
  481. end)
  482.  
  483. if packer_bootstrap then
  484. print '=================================='
  485. print ' Plugins are being installed'
  486. print ' Wait until Packer completes,'
  487. print ' then restart nvim'
  488. print '=================================='
  489. return
  490. end
  491.  
  492.  
Advertisement
Add Comment
Please, Sign In to add comment