aboutsummaryrefslogtreecommitdiffstats
path: root/lua/config
diff options
context:
space:
mode:
Diffstat (limited to 'lua/config')
-rw-r--r--lua/config/editor.lua137
-rw-r--r--lua/config/lsp.lua108
-rw-r--r--lua/config/packer.lua115
3 files changed, 148 insertions, 212 deletions
diff --git a/lua/config/editor.lua b/lua/config/editor.lua
index 9594778..daff2ad 100644
--- a/lua/config/editor.lua
+++ b/lua/config/editor.lua
@@ -1,35 +1,30 @@
1local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" } 1local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" }
2local option = vim.opt; 2local option = vim.opt
3local keymap = vim.keymap; 3local keymap = vim.keymap
4 4
5local dap = require("dap") 5local telescope = require("telescope.builtin")
6local telescope = require('telescope.builtin'); 6local autotag = require("nvim-ts-autotag").setup()
7local autotag = require('nvim-ts-autotag').setup();
8local 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 7
13--Basic Editor Setup 8--Basic Editor Setup
14option.nu = true; 9option.nu = true
15option.tabstop = 2; 10option.tabstop = 2
16option.softtabstop = 2; 11option.softtabstop = 2
17option.shiftwidth = 2; 12option.shiftwidth = 2
18option.expandtab = true; 13option.expandtab = true
19option.smartindent = true; 14option.smartindent = true
20option.wrap = false; 15option.wrap = false
21option.swapfile = false; 16option.swapfile = false
22option.hlsearch = false; 17option.hlsearch = false
23option.incsearch = true; 18option.incsearch = true
24option.updatetime = 50; 19option.updatetime = 50
25option.laststatus = 0; 20option.laststatus = 0
26option.signcolumn = "number"; 21option.signcolumn = "number"
27option.autoindent = true; 22option.autoindent = true
28option.clipboard = "unnamedplus"; 23option.clipboard = "unnamedplus"
29option.termguicolors = true; 24option.termguicolors = true
30 25
31-- Setup Editor Theme 26-- Setup Editor Theme
32vim.cmd.colorscheme("darkblue") 27vim.cmd.colorscheme("gruvbox")
33vim.cmd([[ 28vim.cmd([[
34highlight GitGutterAdd ctermbg=none 29highlight GitGutterAdd ctermbg=none
35highlight GitGutterAdd guibg=none 30highlight GitGutterAdd guibg=none
@@ -39,92 +34,42 @@ highlight signcolumn ctermbg=none
39highlight signcolumn guibg=none 34highlight signcolumn guibg=none
40]]) 35]])
41 36
37
42-- run specific commands after different file extensions 38-- run specific commands after different file extensions
43vim.cmd([[ 39vim.cmd([[
44augroup RunPfOnSave 40augroup RunPfOnSave
45autocmd! 41autocmd!
46autocmd BufWritePost *.js,*.ts,*.jsx,*json !prettier --write % 42autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write %
47autocmd BufWritePost *.tex :VimtexCompile 43autocmd BufWritePost *.tex :VimtexCompile
48autocmd BufWritePost *.md :MarkdownPreview 44autocmd BufWritePost *.md silent! :MarkdownPreview
45autocmd BufWritePost *.php silent! !php-cs-fixer fix %
49augroup END 46augroup END
50]]) 47]])
51 48
52-- Gui options 49-- Gui options
53vim.o.guifont = "Fira Code:h7" 50vim.o.guifont = "Fira Code:h7"
54vim.g.vimtex_view_method = 'zathura' 51vim.g.vimtex_view_method = "zathura"
55vim.g.vimtex_compiler_method = 'latexrun' 52vim.g.vimtex_compiler_method = "latexrun"
56vim.g.gitgutter_set_sign_backgrounds = 1; 53vim.g.gitgutter_set_sign_backgrounds = 1
57vim.fn.sign_define('DapBreakpoint',{ text ='🟥', texthl ='', linehl ='', numhl =''})
58vim.fn.sign_define('DapStopped',{ text ='▶️', texthl ='', linehl ='', numhl =''})
59 54
60--Keybinds 55--Keybinds
61vim.g.mapleader = (" ") 56vim.g.mapleader = " "
62keymap.set("n", "<leader>e", vim.cmd.Ex) 57keymap.set("n", "<leader>e", vim.cmd.Ex)
63keymap.set('n', '<leader>f', telescope.find_files, {}) 58keymap.set("n", "<leader>f", telescope.find_files, {})
64keymap.set('n', '<leader>fg', telescope.live_grep, {}) 59keymap.set("n", "<leader>fg", telescope.live_grep, {})
65keymap.set('n', '<leader>fb', telescope.buffers, {}) 60keymap.set("n", "<leader>fb", telescope.buffers, {})
66keymap.set('n', '<leader>fh', telescope.help_tags, {}) 61keymap.set("n", "<leader>fh", telescope.help_tags, {})
67keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) 62keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
68keymap.set("n", "<leader>a", "ggVG") 63keymap.set("n", "<leader>a", "ggVG")
69keymap.set("v", "J", ":m '>+1<CR>gv=gv") 64keymap.set("v", "J", ":m '>+1<CR>gv=gv")
70keymap.set("v", "K", ":m '<-2<CR>gv=gv") 65keymap.set("v", "K", ":m '<-2<CR>gv=gv")
71 66
72-- Debugger keybinds
73keymap.set('n', '<F5>', require 'dap'.continue)
74keymap.set('n', '<F10>', require 'dap'.step_over)
75keymap.set('n', '<F11>', require 'dap'.step_into)
76keymap.set('n', '<F12>', require 'dap'.step_out)
77keymap.set('n', '<leader>b', require 'dap'.toggle_breakpoint)
78
79keymap.set('n', '<leader>B', function()
80 require 'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))
81end)
82
83keymap.set('n', '<leader>ui', require 'dapui'.toggle)
84for _, language in ipairs(js_based_languages) do
85 require("dap").configurations[language] = {
86 {
87 type = "pwa-node",
88 request = "launch",
89 name = "Launch file",
90 program = "${file}",
91 cwd = "${workspaceFolder}",
92 },
93 {
94 type = "pwa-node",
95 request = "attach",
96 name = "Attach",
97 processId = require 'dap.utils'.pick_process,
98 cwd = "${workspaceFolder}",
99 },
100 {
101 type = "pwa-chrome",
102 request = "launch",
103 name = "Start Chrome with \"localhost\"",
104 url = "http://localhost:3000",
105 webRoot = "${workspaceFolder}",
106 userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir"
107 }
108 }
109end
110require("dapui").setup()
111local dap, dapui = require("dap"), require("dapui")
112dap.listeners.after.event_initialized["dapui_config"] = function()
113 dapui.open({})
114end
115dap.listeners.before.event_terminated["dapui_config"] = function()
116 dapui.close({})
117end
118dap.listeners.before.event_exited["dapui_config"] = function()
119 dapui.close({})
120end
121
122--Treesitter 67--Treesitter
123require 'nvim-treesitter.configs'.setup { 68require("nvim-treesitter.configs").setup({
124 ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim" }, 69 ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim" },
125 sync_install = false, 70 sync_install = false,
126 auto_install = true, 71 auto_install = true,
127 highlight = { 72 highlight = {
128 enable = true, 73 enable = true,
129 } 74 },
130} 75})
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 3fdc2e0..fdcfe99 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -1,78 +1,64 @@
1-- local lsp = require('lsp-zero') 1-- local lsp = require('lsp-zero')
2 2
3local lsp_zero = require('lsp-zero') 3local lsp_zero = require("lsp-zero")
4local cmp = require('cmp') 4local cmp = require("cmp")
5require("luasnip.loaders.from_vscode").lazy_load() 5require("luasnip.loaders.from_vscode").lazy_load()
6 6
7lsp_zero.preset('recommended') 7lsp_zero.preset("recommended")
8lsp_zero.setup() 8lsp_zero.setup()
9lsp_zero.on_attach(function(client, bufnr) 9lsp_zero.on_attach(function(client_id, bufnr)
10 -- see :help lsp-zero-keybindings 10 lsp_zero.default_keymaps({ buffer = bufnr })
11 -- to learn the available actions
12 lsp_zero.default_keymaps({buffer = bufnr})
13end) 11end)
14 12
15require('mason').setup({}) 13require("mason").setup({})
16require('mason-lspconfig').setup({ 14require("mason-lspconfig").setup({
17 -- Replace the language servers listed here 15 ensure_installed = { "tsserver", "rust_analyzer", "eslint" },
18 -- with the ones you want to install 16 handlers = {
19 ensure_installed = {'tsserver', 'rust_analyzer', 'eslint'}, 17 lsp_zero.default_setup,
20 handlers = { 18 },
21 lsp_zero.default_setup,
22 },
23}) 19})
24 20
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
36cmp.setup({ 21cmp.setup({
37 snippet = { 22 snippet = {
38 expand = function(args) 23 expand = function(args)
39 require('luasnip').lsp_expand(args.body) 24 require("luasnip").lsp_expand(args.body)
40 end, 25 end,
41 }, 26 },
42 window = { 27 window = {},
43 }, 28 mapping = cmp.mapping.preset.insert({
44 mapping = cmp.mapping.preset.insert({ 29 ["<C-b>"] = cmp.mapping.scroll_docs(-4),
45 ['<C-b>'] = cmp.mapping.scroll_docs(-4), 30 ["<C-f>"] = cmp.mapping.scroll_docs(4),
46 ['<C-f>'] = cmp.mapping.scroll_docs(4), 31 ["<C-Space>"] = cmp.mapping.complete(),
47 ['<C-Space>'] = cmp.mapping.complete(), 32 ["<C-e>"] = cmp.mapping.abort(),
48 ['<C-e>'] = cmp.mapping.abort(), 33 ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
49 ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. 34 }),
50 }), 35 sources = cmp.config.sources({
51 sources = cmp.config.sources({ 36 { name = "nvim_lsp" },
52 { name = 'nvim_lsp' }, 37 { name = "luasnip" },
53 { name = 'luasnip' }, 38 }, {
54 }, { 39 { name = "buffer" },
55 { name = 'buffer' }, 40 }),
56 })
57}) 41})
58 42
59function PrintDiagnostics(opts, bufnr, line_nr, client_id) 43function PrintDiagnostics(opts, bufnr, line_nr, client_id)
60 bufnr = bufnr or 0 44 bufnr = bufnr or 0
61 line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) 45 line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
62 opts = opts or { ['lnum'] = line_nr } 46 opts = opts or { ["lnum"] = line_nr }
63 47
64 local line_diagnostics = vim.diagnostic.get(bufnr, opts) 48 local line_diagnostics = vim.diagnostic.get(bufnr, opts)
65 if vim.tbl_isempty(line_diagnostics) then return end 49 if vim.tbl_isempty(line_diagnostics) then
50 return
51 end
66 52
67 local diagnostic_message = "" 53 local diagnostic_message = ""
68 for i, diagnostic in ipairs(line_diagnostics) do 54 for i, diagnostic in ipairs(line_diagnostics) do
69 diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") 55 diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
70 print(diagnostic_message) 56 print(diagnostic_message)
71 if i ~= #line_diagnostics then 57 if i ~= #line_diagnostics then
72 diagnostic_message = diagnostic_message .. "\n" 58 diagnostic_message = diagnostic_message .. "\n"
73 end 59 end
74 end 60 end
75 vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) 61 vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {})
76end 62end
77 63
78vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]] 64vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]])
diff --git a/lua/config/packer.lua b/lua/config/packer.lua
index 887b330..36b9058 100644
--- a/lua/config/packer.lua
+++ b/lua/config/packer.lua
@@ -1,56 +1,61 @@
1vim.cmd [[packadd packer.nvim]] 1vim.cmd([[packadd packer.nvim]])
2return require('packer').startup(function(use) 2return require("packer").startup(function(use)
3 use 'wbthomason/packer.nvim' 3 use("wbthomason/packer.nvim")
4 use 'nvim-treesitter/nvim-treesitter' 4 use("nvim-treesitter/nvim-treesitter")
5 use 'neovim/nvim-lspconfig' 5 use("neovim/nvim-lspconfig")
6 use 'lukas-reineke/indent-blankline.nvim' 6 use("lukas-reineke/indent-blankline.nvim")
7 use 'lervag/vimtex' 7 use("lervag/vimtex")
8 use 'morhetz/gruvbox' 8 use("morhetz/gruvbox")
9 use 'airblade/vim-gitgutter' 9 use("airblade/vim-gitgutter")
10 use 'jose-elias-alvarez/null-ls.nvim' 10 use("jose-elias-alvarez/null-ls.nvim")
11 use 'windwp/nvim-ts-autotag' 11 use("windwp/nvim-ts-autotag")
12 use 'lunacookies/vim-colors-xcode' 12 use("lunacookies/vim-colors-xcode")
13 use 'mfussenegger/nvim-dap' 13 use("mfussenegger/nvim-dap")
14 use 'mxsdev/nvim-dap-vscode-js' 14 use("mxsdev/nvim-dap-vscode-js")
15 use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } 15 use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } })
16use { 16 use({
17 'nvim-telescope/telescope.nvim', tag = '0.1.4', 17 "nvim-telescope/telescope.nvim",
18 requires = { {'nvim-lua/plenary.nvim'} } 18 tag = "0.1.4",
19} 19 requires = { { "nvim-lua/plenary.nvim" } },
20 use { 20 })
21 'VonHeikemen/lsp-zero.nvim', 21 use({
22 requires = { 22 "VonHeikemen/lsp-zero.nvim",
23 { 'neovim/nvim-lspconfig' }, 23 requires = {
24 { 'williamboman/mason.nvim' }, 24 { "neovim/nvim-lspconfig" },
25 { 'williamboman/mason-lspconfig.nvim' }, 25 { "williamboman/mason.nvim" },
26 { 'hrsh7th/nvim-cmp' }, 26 { "williamboman/mason-lspconfig.nvim" },
27 { 'hrsh7th/cmp-buffer' }, 27 { "hrsh7th/nvim-cmp" },
28 { 'hrsh7th/cmp-path' }, 28 { "hrsh7th/cmp-buffer" },
29 { 'saadparwaiz1/cmp_luasnip' }, 29 { "hrsh7th/cmp-path" },
30 { 'hrsh7th/cmp-nvim-lsp' }, 30 { "saadparwaiz1/cmp_luasnip" },
31 { 'hrsh7th/cmp-nvim-lua' }, 31 { "hrsh7th/cmp-nvim-lsp" },
32 { 'rafamadriz/friendly-snippets' }, 32 { "hrsh7th/cmp-nvim-lua" },
33 } 33 { "rafamadriz/friendly-snippets" },
34 } 34 },
35 use({ 35 })
36 "L3MON4D3/LuaSnip", 36 use({
37 tag = "v2.*", 37 "L3MON4D3/LuaSnip",
38 run = "make install_jsregexp" 38 tag = "v2.*",
39 }) 39 run = "make install_jsregexp",
40 use { 40 })
41 'numToStr/Comment.nvim', 41 use({
42 config = function() 42 "numToStr/Comment.nvim",
43 require('Comment').setup() 43 config = function()
44 end 44 require("Comment").setup()
45 } 45 end,
46 use({ 46 })
47 "iamcco/markdown-preview.nvim", 47 use({
48 run = "cd app && npm install", 48 "iamcco/markdown-preview.nvim",
49 setup = function() vim.g.mkdp_filetypes = { "markdown" } end, 49 run = "cd app && npm install",
50 ft = { "markdown" }, 50 setup = function()
51 }) 51 vim.g.mkdp_filetypes = { "markdown" }
52 use { 52 end,
53 "windwp/nvim-autopairs", 53 ft = { "markdown" },
54 config = function() require("nvim-autopairs").setup {} end 54 })
55 } 55 use({
56 "windwp/nvim-autopairs",
57 config = function()
58 require("nvim-autopairs").setup({})
59 end,
60 })
56end) 61end)
2'>2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903