diff options
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/editor.lua | 137 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 108 | ||||
| -rw-r--r-- | lua/config/packer.lua | 115 |
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 @@ | |||
| 1 | local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" } | 1 | local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" } |
| 2 | local option = vim.opt; | 2 | local option = vim.opt |
| 3 | local keymap = vim.keymap; | 3 | local keymap = vim.keymap |
| 4 | 4 | ||
| 5 | local dap = require("dap") | 5 | local telescope = require("telescope.builtin") |
| 6 | local telescope = require('telescope.builtin'); | 6 | local autotag = require("nvim-ts-autotag").setup() |
| 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 | 7 | ||
| 13 | --Basic Editor Setup | 8 | --Basic Editor Setup |
| 14 | option.nu = true; | 9 | option.nu = true |
| 15 | option.tabstop = 2; | 10 | option.tabstop = 2 |
| 16 | option.softtabstop = 2; | 11 | option.softtabstop = 2 |
| 17 | option.shiftwidth = 2; | 12 | option.shiftwidth = 2 |
| 18 | option.expandtab = true; | 13 | option.expandtab = true |
| 19 | option.smartindent = true; | 14 | option.smartindent = true |
| 20 | option.wrap = false; | 15 | option.wrap = false |
| 21 | option.swapfile = false; | 16 | option.swapfile = false |
| 22 | option.hlsearch = false; | 17 | option.hlsearch = false |
| 23 | option.incsearch = true; | 18 | option.incsearch = true |
| 24 | option.updatetime = 50; | 19 | option.updatetime = 50 |
| 25 | option.laststatus = 0; | 20 | option.laststatus = 0 |
| 26 | option.signcolumn = "number"; | 21 | option.signcolumn = "number" |
| 27 | option.autoindent = true; | 22 | option.autoindent = true |
| 28 | option.clipboard = "unnamedplus"; | 23 | option.clipboard = "unnamedplus" |
| 29 | option.termguicolors = true; | 24 | option.termguicolors = true |
| 30 | 25 | ||
| 31 | -- Setup Editor Theme | 26 | -- Setup Editor Theme |
| 32 | vim.cmd.colorscheme("darkblue") | 27 | vim.cmd.colorscheme("gruvbox") |
| 33 | vim.cmd([[ | 28 | vim.cmd([[ |
| 34 | highlight GitGutterAdd ctermbg=none | 29 | highlight GitGutterAdd ctermbg=none |
| 35 | highlight GitGutterAdd guibg=none | 30 | highlight GitGutterAdd guibg=none |
| @@ -39,92 +34,42 @@ highlight signcolumn ctermbg=none | |||
| 39 | highlight signcolumn guibg=none | 34 | highlight signcolumn guibg=none |
| 40 | ]]) | 35 | ]]) |
| 41 | 36 | ||
| 37 | |||
| 42 | -- run specific commands after different file extensions | 38 | -- run specific commands after different file extensions |
| 43 | vim.cmd([[ | 39 | vim.cmd([[ |
| 44 | augroup RunPfOnSave | 40 | augroup RunPfOnSave |
| 45 | autocmd! | 41 | autocmd! |
| 46 | autocmd BufWritePost *.js,*.ts,*.jsx,*json !prettier --write % | 42 | autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write % |
| 47 | autocmd BufWritePost *.tex :VimtexCompile | 43 | autocmd BufWritePost *.tex :VimtexCompile |
| 48 | autocmd BufWritePost *.md :MarkdownPreview | 44 | autocmd BufWritePost *.md silent! :MarkdownPreview |
| 45 | autocmd BufWritePost *.php silent! !php-cs-fixer fix % | ||
| 49 | augroup END | 46 | augroup END |
| 50 | ]]) | 47 | ]]) |
| 51 | 48 | ||
| 52 | -- Gui options | 49 | -- Gui options |
| 53 | vim.o.guifont = "Fira Code:h7" | 50 | vim.o.guifont = "Fira Code:h7" |
| 54 | vim.g.vimtex_view_method = 'zathura' | 51 | vim.g.vimtex_view_method = "zathura" |
| 55 | vim.g.vimtex_compiler_method = 'latexrun' | 52 | vim.g.vimtex_compiler_method = "latexrun" |
| 56 | vim.g.gitgutter_set_sign_backgrounds = 1; | 53 | vim.g.gitgutter_set_sign_backgrounds = 1 |
| 57 | vim.fn.sign_define('DapBreakpoint',{ text ='🟥', texthl ='', linehl ='', numhl =''}) | ||
| 58 | vim.fn.sign_define('DapStopped',{ text ='▶️', texthl ='', linehl ='', numhl =''}) | ||
| 59 | 54 | ||
| 60 | --Keybinds | 55 | --Keybinds |
| 61 | vim.g.mapleader = (" ") | 56 | vim.g.mapleader = " " |
| 62 | keymap.set("n", "<leader>e", vim.cmd.Ex) | 57 | keymap.set("n", "<leader>e", vim.cmd.Ex) |
| 63 | keymap.set('n', '<leader>f', telescope.find_files, {}) | 58 | keymap.set("n", "<leader>f", telescope.find_files, {}) |
| 64 | keymap.set('n', '<leader>fg', telescope.live_grep, {}) | 59 | keymap.set("n", "<leader>fg", telescope.live_grep, {}) |
| 65 | keymap.set('n', '<leader>fb', telescope.buffers, {}) | 60 | keymap.set("n", "<leader>fb", telescope.buffers, {}) |
| 66 | keymap.set('n', '<leader>fh', telescope.help_tags, {}) | 61 | keymap.set("n", "<leader>fh", telescope.help_tags, {}) |
| 67 | keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) | 62 | keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) |
| 68 | keymap.set("n", "<leader>a", "ggVG") | 63 | keymap.set("n", "<leader>a", "ggVG") |
| 69 | keymap.set("v", "J", ":m '>+1<CR>gv=gv") | 64 | keymap.set("v", "J", ":m '>+1<CR>gv=gv") |
| 70 | keymap.set("v", "K", ":m '<-2<CR>gv=gv") | 65 | keymap.set("v", "K", ":m '<-2<CR>gv=gv") |
| 71 | 66 | ||
| 72 | -- Debugger keybinds | ||
| 73 | keymap.set('n', '<F5>', require 'dap'.continue) | ||
| 74 | keymap.set('n', '<F10>', require 'dap'.step_over) | ||
| 75 | keymap.set('n', '<F11>', require 'dap'.step_into) | ||
| 76 | keymap.set('n', '<F12>', require 'dap'.step_out) | ||
| 77 | keymap.set('n', '<leader>b', require 'dap'.toggle_breakpoint) | ||
| 78 | |||
| 79 | keymap.set('n', '<leader>B', function() | ||
| 80 | require 'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) | ||
| 81 | end) | ||
| 82 | |||
| 83 | keymap.set('n', '<leader>ui', require 'dapui'.toggle) | ||
| 84 | for _, 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 | } | ||
| 109 | end | ||
| 110 | require("dapui").setup() | ||
| 111 | local dap, dapui = require("dap"), require("dapui") | ||
| 112 | dap.listeners.after.event_initialized["dapui_config"] = function() | ||
| 113 | dapui.open({}) | ||
| 114 | end | ||
| 115 | dap.listeners.before.event_terminated["dapui_config"] = function() | ||
| 116 | dapui.close({}) | ||
| 117 | end | ||
| 118 | dap.listeners.before.event_exited["dapui_config"] = function() | ||
| 119 | dapui.close({}) | ||
| 120 | end | ||
| 121 | |||
| 122 | --Treesitter | 67 | --Treesitter |
| 123 | require 'nvim-treesitter.configs'.setup { | 68 | require("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 | ||
| 3 | local lsp_zero = require('lsp-zero') | 3 | local lsp_zero = require("lsp-zero") |
| 4 | local cmp = require('cmp') | 4 | local cmp = require("cmp") |
| 5 | require("luasnip.loaders.from_vscode").lazy_load() | 5 | require("luasnip.loaders.from_vscode").lazy_load() |
| 6 | 6 | ||
| 7 | lsp_zero.preset('recommended') | 7 | lsp_zero.preset("recommended") |
| 8 | lsp_zero.setup() | 8 | lsp_zero.setup() |
| 9 | lsp_zero.on_attach(function(client, bufnr) | 9 | lsp_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}) | ||
| 13 | end) | 11 | end) |
| 14 | 12 | ||
| 15 | require('mason').setup({}) | 13 | require("mason").setup({}) |
| 16 | require('mason-lspconfig').setup({ | 14 | require("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 | |||
| 36 | cmp.setup({ | 21 | cmp.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 | ||
| 59 | function PrintDiagnostics(opts, bufnr, line_nr, client_id) | 43 | function 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, {}) |
| 76 | end | 62 | end |
| 77 | 63 | ||
| 78 | vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]] | 64 | vim.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 @@ | |||
| 1 | vim.cmd [[packadd packer.nvim]] | 1 | vim.cmd([[packadd packer.nvim]]) |
| 2 | return require('packer').startup(function(use) | 2 | return 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" } }) |
| 16 | use { | 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 | }) | ||
| 56 | end) | 61 | end) |
