diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | README.md | 66 | ||||
| -rw-r--r-- | init.lua | 17 | ||||
| -rw-r--r-- | lua/config/editor.lua | 140 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 78 | ||||
| -rw-r--r-- | lua/config/packer.lua | 61 |
6 files changed, 363 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7ad043 --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| plugin/ | |||
diff --git a/README.md b/README.md new file mode 100644 index 0000000..08b4293 --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | # My Neovim Config | ||
| 2 |  | ||
| 3 | |||
| 4 | ### Introduction | ||
| 5 | Run checkhealth in your Neovim | ||
| 6 | ```vim | ||
| 7 | :checkhealth | ||
| 8 | ``` | ||
| 9 | Make sure you analyzed the output properly: | ||
| 10 | - Your neovim must be >= 0.7.0 to run this config | ||
| 11 | - You need to setup [Packer](https://github.com/wbthomason/packer.nvim) | ||
| 12 | ```vim | ||
| 13 | git clone --depth 1 https://github.com/wbthomason/packer.nvim\ | ||
| 14 | ~/.local/share/nvim/site/pack/packer/start/packer.nvim | ||
| 15 | ``` | ||
| 16 | - You should install global python provider | ||
| 17 | ```python | ||
| 18 | pip install pynvim | ||
| 19 | ``` | ||
| 20 | - You should install clipboard tool (I use xclip but you can use something diffrent) | ||
| 21 | |||
| 22 | ### Installation | ||
| 23 | > Easy way | ||
| 24 | |||
| 25 | You can just clone this repo to your .config folder | ||
| 26 | |||
| 27 | ```bash | ||
| 28 | git clone https://github.com/dsrcr/nvim ~/.config | ||
| 29 | ``` | ||
| 30 | > Recommended way | ||
| 31 | |||
| 32 | I use gnu-stow to manage my dotfiles, so I encourage you to use it too. | ||
| 33 | |||
| 34 | Use your package manage of choice to get stow, for example: | ||
| 35 | |||
| 36 | ```bash | ||
| 37 | paru -S stow | ||
| 38 | ``` | ||
| 39 | Clone this repo to your prefered dir and use stow to symlink | ||
| 40 | |||
| 41 | In order to do this you need an empty nvim directory in your .config folder | ||
| 42 | ```bash | ||
| 43 | cd ~/.config | ||
| 44 | mkdir nvim | ||
| 45 | cd ~/yourDirectory | ||
| 46 | git clone https://github.com/dsrcr/nvim | ||
| 47 | stow -d ~/yourDirectory -t ~/.config/nvim nvim/ | ||
| 48 | |||
| 49 | ``` | ||
| 50 | |||
| 51 | The last step is running this command in your neovim | ||
| 52 | |||
| 53 | ```vim | ||
| 54 | :PackerSync | ||
| 55 | ``` | ||
| 56 | This command should pull everything you need | ||
| 57 | |||
| 58 | In the next step you will encounter a lot of errors, but don't worry about it. | ||
| 59 | Packer needs to pull specific plugins and then you need to install Treesitter's support for specific filetypes eg. lua, rust.... etc. | ||
| 60 | ```bash | ||
| 61 | :TSUpdate | ||
| 62 | ``` | ||
| 63 | ```bash | ||
| 64 | :TSInstall | ||
| 65 | ``` | ||
| 66 | |||
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6d26278 --- /dev/null +++ b/init.lua | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | -- ________ _________ _____ .__ ____ | ||
| 2 | -- \______ \ / _____/ ____ ____ ____ _/ ____\|__| / ___\ | ||
| 3 | -- | | \ \_____ \ _/ ___\ / _ \ / \\ __\ | | / /_/ > | ||
| 4 | -- | ` \ / \\ \___( <_> )| | \| | | | \___ / | ||
| 5 | -- /_______ //_______ / \___ >\____/ |___| /|__| |__|/_____/ | ||
| 6 | -- \/ \/ \/ \/ | ||
| 7 | -- Starting point for my neovim setup | ||
| 8 | -- https://github.com/dsrcr/nvim | ||
| 9 | |||
| 10 | --Open this file if you want to add new plugins | ||
| 11 | require("config.packer") | ||
| 12 | |||
| 13 | -- You can find here stuff related to lsp | ||
| 14 | require("config.lsp") | ||
| 15 | |||
| 16 | -- You can customize editor | ||
| 17 | require("config.editor") | ||
diff --git a/lua/config/editor.lua b/lua/config/editor.lua new file mode 100644 index 0000000..3db21d6 --- /dev/null +++ b/lua/config/editor.lua | |||
| @@ -0,0 +1,140 @@ | |||
| 1 | local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" } | ||
| 2 | local option = vim.opt; | ||
| 3 | local keymap = vim.keymap; | ||
| 4 | |||
| 5 | local dap = require("dap") | ||
| 6 | local telescope = require('telescope.builtin'); | ||
| 7 | local autotag = require('nvim-ts-autotag').setup(); | ||
| 8 | local dap_vscode = require("dap-vscode-js").setup({ | ||
| 9 | debugger_path = "(runtimedir)/site/pack/packer/opt/vscode-js-debug", | ||
| 10 | adapters = { 'chrome', 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost', 'node', 'chrome' }, | ||
| 11 | }) | ||
| 12 | |||
| 13 | --Basic Editor Setup | ||
| 14 | option.nu = true; | ||
| 15 | option.tabstop = 2; | ||
| 16 | option.softtabstop = 2; | ||
| 17 | option.shiftwidth = 2; | ||
| 18 | option.expandtab = true; | ||
| 19 | option.smartindent = true; | ||
| 20 | option.wrap = false; | ||
| 21 | option.swapfile = false; | ||
| 22 | option.hlsearch = false; | ||
| 23 | option.incsearch = true; | ||
| 24 | option.updatetime = 50; | ||
| 25 | option.laststatus = 0; | ||
| 26 | option.signcolumn = "number"; | ||
| 27 | option.autoindent = true; | ||
| 28 | option.clipboard = "unnamedplus"; | ||
| 29 | option.termguicolors = true; | ||
| 30 | |||
| 31 | -- Setup Editor Theme | ||
| 32 | vim.cmd.colorscheme("gruvbox") | ||
| 33 | vim.cmd([[ | ||
| 34 | highlight GitGutterAdd ctermbg=none | ||
| 35 | highlight GitGutterAdd guibg=none | ||
| 36 | highlight Normal ctermbg=none | ||
| 37 | highlight Normal guibg=none | ||
| 38 | highlight signcolumn ctermbg=none | ||
| 39 | highlight signcolumn guibg=none | ||
| 40 | ]]) | ||
| 41 | |||
| 42 | -- run specific commands after different file extensions | ||
| 43 | vim.cmd([[ | ||
| 44 | augroup RunPfOnSave | ||
| 45 | autocmd! | ||
| 46 | autocmd BufWritePost *.js,*.ts,*.jsx,*json !prettier --write . | ||
| 47 | autocmd BufWritePost *.tex :VimtexCompile | ||
| 48 | autocmd BufWritePost *.md :MarkdownPreview | ||
| 49 | augroup END | ||
| 50 | ]]) | ||
| 51 | |||
| 52 | -- vim.cmd([[ | ||
| 53 | -- augroup RunPfOnSave | ||
| 54 | -- autocmd! | ||
| 55 | -- augroup END | ||
| 56 | -- ]]) | ||
| 57 | -- | ||
| 58 | -- vim.cmd([[ | ||
| 59 | -- augroup RunPfOnSave | ||
| 60 | -- autocmd! | ||
| 61 | -- autocmd BufWritePost *.tex :VimtexCompile | ||
| 62 | -- augroup END | ||
| 63 | --]]) | ||
| 64 | |||
| 65 | -- Gui options | ||
| 66 | vim.o.guifont = "Fira Code:h7" | ||
| 67 | vim.g.vimtex_view_method = 'zathura' | ||
| 68 | vim.g.vimtex_compiler_method = 'latexrun' | ||
| 69 | vim.g.gitgutter_set_sign_backgrounds = 1; | ||
| 70 | vim.fn.sign_define('DapBreakpoint',{ text ='🟥', texthl ='', linehl ='', numhl =''}) | ||
| 71 | vim.fn.sign_define('DapStopped',{ text ='▶️', texthl ='', linehl ='', numhl =''}) | ||
| 72 | |||
| 73 | --Keybinds | ||
| 74 | vim.g.mapleader = (" ") | ||
| 75 | keymap.set("n", "<leader>e", vim.cmd.Ex) | ||
| 76 | keymap.set('n', '<leader>f', telescope.find_files, {}) | ||
| 77 | keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) | ||
| 78 | keymap.set("n", "<leader>a", "ggVG") | ||
| 79 | keymap.set("v", "J", ":m '>+1<CR>gv=gv") | ||
| 80 | keymap.set("v", "K", ":m '<-2<CR>gv=gv") | ||
| 81 | |||
| 82 | -- Debugger keybinds | ||
| 83 | keymap.set('n', '<F5>', require 'dap'.continue) | ||
| 84 | keymap.set('n', '<F10>', require 'dap'.step_over) | ||
| 85 | keymap.set('n', '<F11>', require 'dap'.step_into) | ||
| 86 | keymap.set('n', '<F12>', require 'dap'.step_out) | ||
| 87 | keymap.set('n', '<leader>b', require 'dap'.toggle_breakpoint) | ||
| 88 | |||
| 89 | keymap.set('n', '<leader>B', function() | ||
| 90 | require 'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) | ||
| 91 | end) | ||
| 92 | |||
| 93 | keymap.set('n', '<leader>ui', require 'dapui'.toggle) | ||
| 94 | for _, language in ipairs(js_based_languages) do | ||
| 95 | require("dap").configurations[language] = { | ||
| 96 | { | ||
| 97 | type = "pwa-node", | ||
| 98 | request = "launch", | ||
| 99 | name = "Launch file", | ||
| 100 | program = "${file}", | ||
| 101 | cwd = "${workspaceFolder}", | ||
| 102 | }, | ||
| 103 | { | ||
| 104 | type = "pwa-node", | ||
| 105 | request = "attach", | ||
| 106 | name = "Attach", | ||
| 107 | processId = require 'dap.utils'.pick_process, | ||
| 108 | cwd = "${workspaceFolder}", | ||
| 109 | }, | ||
| 110 | { | ||
| 111 | type = "pwa-chrome", | ||
| 112 | request = "launch", | ||
| 113 | name = "Start Chrome with \"localhost\"", | ||
| 114 | url = "http://localhost:3000", | ||
| 115 | webRoot = "${workspaceFolder}", | ||
| 116 | userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir" | ||
| 117 | } | ||
| 118 | } | ||
| 119 | end | ||
| 120 | require("dapui").setup() | ||
| 121 | local dap, dapui = require("dap"), require("dapui") | ||
| 122 | dap.listeners.after.event_initialized["dapui_config"] = function() | ||
| 123 | dapui.open({}) | ||
| 124 | end | ||
| 125 | dap.listeners.before.event_terminated["dapui_config"] = function() | ||
| 126 | dapui.close({}) | ||
| 127 | end | ||
| 128 | dap.listeners.before.event_exited["dapui_config"] = function() | ||
| 129 | dapui.close({}) | ||
| 130 | end | ||
| 131 | |||
| 132 | --Treesitter | ||
| 133 | require 'nvim-treesitter.configs'.setup { | ||
| 134 | ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim" }, | ||
| 135 | sync_install = false, | ||
| 136 | auto_install = true, | ||
| 137 | highlight = { | ||
| 138 | enable = true, | ||
| 139 | } | ||
| 140 | } | ||
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..623aab3 --- /dev/null +++ b/lua/config/lsp.lua | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | -- local lsp = require('lsp-zero') | ||
| 2 | |||
| 3 | local lsp_zero = require('lsp-zero') | ||
| 4 | local cmp = require('cmp') | ||
| 5 | require("luasnip.loaders.from_vscode").lazy_load() | ||
| 6 | |||
| 7 | lsp_zero.preset('recommended') | ||
| 8 | lsp_zero.setup() | ||
| 9 | lsp_zero.on_attach(function(client, bufnr) | ||
| 10 | -- see :help lsp-zero-keybindings | ||
| 11 | -- to learn the available actions | ||
| 12 | lsp_zero.default_keymaps({buffer = bufnr}) | ||
| 13 | end) | ||
| 14 | |||
| 15 | require('mason').setup({}) | ||
| 16 | require('mason-lspconfig').setup({ | ||
| 17 | -- Replace the language servers listed here | ||
| 18 | -- with the ones you want to install | ||
| 19 | ensure_installed = {'tsserver', 'rust_analyzer', 'eslint'}, | ||
| 20 | handlers = { | ||
| 21 | lsp_zero.default_setup, | ||
| 22 | }, | ||
| 23 | }) | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | require('tabnine').setup({ | ||
| 28 | disable_auto_comment=true, | ||
| 29 | accept_keymap="<Tab>", | ||
| 30 | dismiss_keymap = "<C-]>", | ||
| 31 | debounce_ms = 800, | ||
| 32 | suggestion_color = {gui = "#808080", cterm = 244}, | ||
| 33 | execlude_filetypes = {"TelescopePrompt"} | ||
| 34 | }) | ||
| 35 | |||
| 36 | cmp.setup({ | ||
| 37 | snippet = { | ||
| 38 | expand = function(args) | ||
| 39 | require('luasnip').lsp_expand(args.body) | ||
| 40 | end, | ||
| 41 | }, | ||
| 42 | window = { | ||
| 43 | }, | ||
| 44 | mapping = cmp.mapping.preset.insert({ | ||
| 45 | ['<C-b>'] = cmp.mapping.scroll_docs(-4), | ||
| 46 | ['<C-f>'] = cmp.mapping.scroll_docs(4), | ||
| 47 | ['<C-Space>'] = cmp.mapping.complete(), | ||
| 48 | ['<C-e>'] = cmp.mapping.abort(), | ||
| 49 | ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | ||
| 50 | }), | ||
| 51 | sources = cmp.config.sources({ | ||
| 52 | { name = 'nvim_lsp' }, | ||
| 53 | { name = 'luasnip' }, | ||
| 54 | }, { | ||
| 55 | { name = 'buffer' }, | ||
| 56 | }) | ||
| 57 | }) | ||
| 58 | |||
| 59 | function PrintDiagnostics(opts, bufnr, line_nr, client_id) | ||
| 60 | bufnr = bufnr or 0 | ||
| 61 | line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) | ||
| 62 | opts = opts or { ['lnum'] = line_nr } | ||
| 63 | |||
| 64 | local line_diagnostics = vim.diagnostic.get(bufnr, opts) | ||
| 65 | if vim.tbl_isempty(line_diagnostics) then return end | ||
| 66 | |||
| 67 | local diagnostic_message = "" | ||
| 68 | for i, diagnostic in ipairs(line_diagnostics) do | ||
| 69 | diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") | ||
| 70 | print(diagnostic_message) | ||
| 71 | if i ~= #line_diagnostics then | ||
| 72 | diagnostic_message = diagnostic_message .. "\n" | ||
| 73 | end | ||
| 74 | end | ||
| 75 | vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) | ||
| 76 | end | ||
| 77 | |||
| 78 | vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]] | ||
diff --git a/lua/config/packer.lua b/lua/config/packer.lua new file mode 100644 index 0000000..99af8d4 --- /dev/null +++ b/lua/config/packer.lua | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | vim.cmd [[packadd packer.nvim]] | ||
| 2 | return require('packer').startup(function(use) | ||
| 3 | use 'wbthomason/packer.nvim' | ||
| 4 | use 'nvim-treesitter/nvim-treesitter' | ||
| 5 | use 'neovim/nvim-lspconfig' | ||
| 6 | use 'lukas-reineke/indent-blankline.nvim' | ||
| 7 | use 'lervag/vimtex' | ||
| 8 | use 'morhetz/gruvbox' | ||
| 9 | use 'airblade/vim-gitgutter' | ||
| 10 | use 'catppuccin/nvim' | ||
| 11 | use 'jose-elias-alvarez/null-ls.nvim' | ||
| 12 | use 'windwp/nvim-ts-autotag' | ||
| 13 | use 'mfussenegger/nvim-dap' | ||
| 14 | use 'mxsdev/nvim-dap-vscode-js' | ||
| 15 | use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } | ||
| 16 | use { | ||
| 17 | 'nvim-telescope/telescope.nvim', tag = '0.1.0', | ||
| 18 | requires = { { 'nvim-lua/plenary.nvim' } } | ||
| 19 | } | ||
| 20 | use { | ||
| 21 | 'VonHeikemen/lsp-zero.nvim', | ||
| 22 | requires = { | ||
| 23 | { 'neovim/nvim-lspconfig' }, | ||
| 24 | { 'williamboman/mason.nvim' }, | ||
| 25 | { 'williamboman/mason-lspconfig.nvim' }, | ||
| 26 | { 'hrsh7th/nvim-cmp' }, | ||
| 27 | { 'hrsh7th/cmp-buffer' }, | ||
| 28 | { 'hrsh7th/cmp-path' }, | ||
| 29 | { 'saadparwaiz1/cmp_luasnip' }, | ||
| 30 | { 'hrsh7th/cmp-nvim-lsp' }, | ||
| 31 | { 'hrsh7th/cmp-nvim-lua' }, | ||
| 32 | { 'rafamadriz/friendly-snippets' }, | ||
| 33 | } | ||
| 34 | } | ||
| 35 | use({ | ||
| 36 | "L3MON4D3/LuaSnip", | ||
| 37 | -- follow latest release. | ||
| 38 | tag = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release) | ||
| 39 | -- install jsregexp (optional!:). | ||
| 40 | run = "make install_jsregexp" | ||
| 41 | }) | ||
| 42 | use { | ||
| 43 | 'numToStr/Comment.nvim', | ||
| 44 | config = function() | ||
| 45 | require('Comment').setup() | ||
| 46 | end | ||
| 47 | } | ||
| 48 | use({ | ||
| 49 | "iamcco/markdown-preview.nvim", | ||
| 50 | run = "cd app && npm install", | ||
| 51 | setup = function() vim.g.mkdp_filetypes = { "markdown" } end, | ||
| 52 | ft = { "markdown" }, | ||
| 53 | }) | ||
| 54 | use { | ||
| 55 | "windwp/nvim-autopairs", | ||
| 56 | config = function() require("nvim-autopairs").setup {} end | ||
| 57 | } | ||
| 58 | use { 'codota/tabnine-nvim', run = "./dl_binaries.sh" } | ||
| 59 | |||
| 60 | |||
| 61 | end) | ||
