diff options
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 169 |
1 files changed, 163 insertions, 6 deletions
| @@ -1,8 +1,165 @@ | |||
| 1 | --Open this file if you want to add new plugins | 1 | -- require("config.lsp") |
| 2 | require("config.packer") | 2 | local option = vim.opt |
| 3 | local keymap = vim.keymap | ||
| 3 | 4 | ||
| 4 | -- Here you can find stuff related to lsp | 5 | --Basic Editor Setup |
| 5 | require("config.lsp") | 6 | option.nu = true |
| 7 | option.tabstop = 2 | ||
| 8 | option.softtabstop = 2 | ||
| 9 | option.shiftwidth = 2 | ||
| 10 | option.expandtab = true | ||
| 11 | option.smartindent = true | ||
| 12 | option.wrap = false | ||
| 13 | option.swapfile = false | ||
| 14 | option.hlsearch = false | ||
| 15 | option.incsearch = true | ||
| 16 | option.updatetime = 50 | ||
| 17 | option.laststatus = 0 | ||
| 18 | option.signcolumn = "number" | ||
| 19 | option.autoindent = true | ||
| 20 | option.clipboard = "unnamedplus" | ||
| 21 | option.termguicolors = true | ||
| 22 | option.fillchars = 'eob: ' | ||
| 23 | option.autoindent = true | ||
| 6 | 24 | ||
| 7 | -- And there goes editor customization | 25 | -- Setup Editor Theme |
| 8 | require("config.editor") | 26 | vim.cmd([[ |
| 27 | highlight GitGutterAdd ctermbg=none | ||
| 28 | highlight GitGutterAdd guibg=none | ||
| 29 | highlight NonText guifg=none | ||
| 30 | highlight EndOfBuffer ctermfg=none ctermbg=none | ||
| 31 | highlight Normal ctermbg=none | ||
| 32 | highlight Normal guibg=none | ||
| 33 | highlight signcolumn ctermbg=none | ||
| 34 | highlight signcolumn guibg=none | ||
| 35 | highlight StatusLine ctermbg=none | ||
| 36 | highlight StatusLine guibg=none | ||
| 37 | highlight DiagnosticError ctermbg=none | ||
| 38 | highlight DiagnosticError guibg=none | ||
| 39 | highlight DiagnosticWarn ctermbg=none | ||
| 40 | highlight DiagnosticWarn guibg=none | ||
| 41 | highlight DiagnosticInfo ctermbg=none | ||
| 42 | highlight DiagnosticInfo guibg=none | ||
| 43 | highlight DiagnosticHint ctermbg=none | ||
| 44 | highlight DiagnosticHint guibg=none | ||
| 45 | highlight Pmenu ctermbg=none guibg=none | ||
| 46 | |||
| 47 | highlight DiagnosticVirtualError ctermbg=none | ||
| 48 | highlight DiagnosticVirtualError guibg=none | ||
| 49 | highlight DiagnosticVirtualWarn ctermbg=none | ||
| 50 | highlight DiagnosticVirtualWarn guibg=none | ||
| 51 | highlight DiagnosticVirtualInfo ctermbg=none | ||
| 52 | highlight DiagnosticVirtualInfo guibg=none | ||
| 53 | highlight DiagnosticVirtualHint ctermbg=none | ||
| 54 | highlight DiagnosticVirtualHint guibg=none | ||
| 55 | |||
| 56 | highlight DiagnosticVirtualTextError ctermbg=none | ||
| 57 | highlight DiagnosticVirtualTextError guibg=none | ||
| 58 | highlight DiagnosticVirtualTextWarn ctermbg=none | ||
| 59 | highlight DiagnosticVirtualTextWarn guibg=none | ||
| 60 | highlight DiagnosticVirtualTextInfo ctermbg=none | ||
| 61 | highlight DiagnosticVirtualTextInfo guibg=none | ||
| 62 | highlight DiagnosticVirtualTextHint ctermbg=none | ||
| 63 | highlight DiagnosticVirtualTextHint guibg=none | ||
| 64 | ]]) | ||
| 65 | |||
| 66 | -- run specific commands after different file extensions | ||
| 67 | vim.cmd([[ | ||
| 68 | augroup RunPfOnSave | ||
| 69 | autocmd! | ||
| 70 | autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write % | ||
| 71 | autocmd BufWritePost *.tex silent! :VimtexCompile | ||
| 72 | autocmd BufWritePost *.md silent! :MarkdownPreview | ||
| 73 | autocmd BufWritePost *.php silent! !php-cs-fixer fix % | ||
| 74 | augroup END | ||
| 75 | ]]) | ||
| 76 | |||
| 77 | -- Gui options | ||
| 78 | vim.o.guifont = "Fira Code:h7" | ||
| 79 | vim.g.vimtex_view_method = "zathura" | ||
| 80 | vim.g.vimtex_compiler_method = "latexrun" | ||
| 81 | vim.g.gitgutter_set_sign_backgrounds = 1 | ||
| 82 | |||
| 83 | --Keybinds | ||
| 84 | vim.g.mapleader = " " | ||
| 85 | keymap.set("n", "<leader>e", vim.cmd.Ex) | ||
| 86 | keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) | ||
| 87 | keymap.set("n", "<leader>a", "ggVG") | ||
| 88 | keymap.set("v", "J", ":m '>+1<CR>gv=gv") | ||
| 89 | keymap.set("v", "K", ":m '<-2<CR>gv=gv") | ||
| 90 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | ||
| 91 | if not vim.loop.fs_stat(lazypath) then | ||
| 92 | vim.fn.system({ | ||
| 93 | "git", | ||
| 94 | "clone", | ||
| 95 | "--filter=blob:none", | ||
| 96 | "https://github.com/folke/lazy.nvim.git", | ||
| 97 | "--branch=stable", -- latest stable release | ||
| 98 | lazypath, | ||
| 99 | }) | ||
| 100 | end | ||
| 101 | |||
| 102 | vim.opt.rtp:prepend(lazypath) | ||
| 103 | require("lazy").setup({ | ||
| 104 | "nvim-lua/plenary.nvim", | ||
| 105 | "airblade/vim-gitgutter", | ||
| 106 | "nvim-treesitter/nvim-treesitter", | ||
| 107 | "neovim/nvim-lspconfig", | ||
| 108 | "williamboman/mason.nvim", | ||
| 109 | "williamboman/mason-lspconfig.nvim", | ||
| 110 | 'nvim-telescope/telescope.nvim', | ||
| 111 | tag = '0.1.5', | ||
| 112 | dependencies = { 'nvim-lua/plenary.nvim' }, | ||
| 113 | "windwp/nvim-autopairs", | ||
| 114 | config = function() | ||
| 115 | require("nvim-autopairs").setup({}) | ||
| 116 | end, | ||
| 117 | { | ||
| 118 | 'nvim-telescope/telescope-fzf-native.nvim', | ||
| 119 | build = | ||
| 120 | 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', | ||
| 121 | keys = { | ||
| 122 | { "<leader>/", false }, | ||
| 123 | { "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find Files" }, | ||
| 124 | { "<leader>g", "<cmd>Telescope live_grep<cr>", desc = "Grep" }, | ||
| 125 | { "<leader>b", "<cmd>Telescope buffers<cr>", desc = "Grep" }, | ||
| 126 | } | ||
| 127 | }, | ||
| 128 | { | ||
| 129 | 'numToStr/Comment.nvim', | ||
| 130 | }, | ||
| 131 | |||
| 132 | 'ms-jpq/coq_nvim', | ||
| 133 | { 'ms-jpq/coq.artifacts', branch = "artifacts" }, | ||
| 134 | }) | ||
| 135 | |||
| 136 | |||
| 137 | vim.api.nvim_create_autocmd('InsertEnter', { | ||
| 138 | command = 'COQnow --shut-up' | ||
| 139 | }) | ||
| 140 | local lsp_servers = { | ||
| 141 | clangd = {}, | ||
| 142 | lua_ls = {}, | ||
| 143 | } | ||
| 144 | require("mason").setup() | ||
| 145 | require("mason-lspconfig").setup { | ||
| 146 | ensure_installed = lsp_servers, | ||
| 147 | automatic_installation = true, | ||
| 148 | } | ||
| 149 | |||
| 150 | local server_maps = function(opts) | ||
| 151 | vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- goto def | ||
| 152 | vim.keymap.set("n", "<leader>k", vim.lsp.buf.hover, opts) -- see docs | ||
| 153 | vim.keymap.set("n", "<leader>fo", function() -- format | ||
| 154 | vim.lsp.buf.format({ async = true }) | ||
| 155 | end, opts) | ||
| 156 | end | ||
| 157 | |||
| 158 | for lsp, settings in pairs(lsp_servers) do | ||
| 159 | require("lspconfig")[lsp].setup(coq.lsp_ensure_capabilities({ | ||
| 160 | on_attach = function(_, buffer) | ||
| 161 | server_maps({ buffer = buffer }) | ||
| 162 | end, | ||
| 163 | settings = settings, | ||
| 164 | })) | ||
| 165 | end | ||
