diff options
| author | jdhao <jdhao@hotmail.com> | 2021-08-18 01:43:08 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2021-08-18 01:43:08 +0800 |
| commit | bac94b47a085583db5b200c5d0fdf47d8cff4139 (patch) | |
| tree | 24342b5767a853defb7cccdd77aed288575479c9 /lua/config | |
| parent | 61d6045e671853c81d7a7853ef7f4ef4674366a8 (diff) | |
Format with stylua
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/bqf.lua | 4 | ||||
| -rw-r--r-- | lua/config/compe.lua | 62 | ||||
| -rw-r--r-- | lua/config/indent-blankline.lua | 4 | ||||
| -rw-r--r-- | lua/config/iron.lua | 10 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 185 | ||||
| -rw-r--r-- | lua/config/neoscroll.lua | 24 | ||||
| -rw-r--r-- | lua/config/nvim-bufferline.lua | 22 | ||||
| -rw-r--r-- | lua/config/treesitter.lua | 12 |
8 files changed, 161 insertions, 162 deletions
diff --git a/lua/config/bqf.lua b/lua/config/bqf.lua index 527405a..5ef5d5b 100644 --- a/lua/config/bqf.lua +++ b/lua/config/bqf.lua @@ -1,3 +1,3 @@ -require('bqf').setup({ - auto_resize_height=false +require("bqf").setup({ + auto_resize_height = false, }) diff --git a/lua/config/compe.lua b/lua/config/compe.lua index 2e8764a..5286a9d 100644 --- a/lua/config/compe.lua +++ b/lua/config/compe.lua @@ -1,38 +1,38 @@ -- nvim-compe settings -require'compe'.setup { - enabled = true; - autocomplete = true; - debug = false; - min_length = 1; - preselect = 'enable'; - throttle_time = 80; - source_timeout = 200; - incomplete_delay = 400; - max_abbr_width = 100; - max_kind_width = 100; - max_menu_width = 100; - documentation = true; +require("compe").setup({ + enabled = true, + autocomplete = true, + debug = false, + min_length = 1, + preselect = "enable", + throttle_time = 80, + source_timeout = 200, + incomplete_delay = 400, + max_abbr_width = 100, + max_kind_width = 100, + max_menu_width = 100, + documentation = true, source = { - omni = {filetypes = {'tex'}}; - path = true; - buffer = false; - spell = {filetypes = {'markdown', 'tex'}}; - emoji = true; - nvim_lsp = true; - nvim_lua = true; - ultisnips = true; - calc = false; - vsnip = false; - }; -} + omni = { filetypes = { "tex" } }, + path = true, + buffer = false, + spell = { filetypes = { "markdown", "tex" } }, + emoji = true, + nvim_lsp = true, + nvim_lua = true, + ultisnips = true, + calc = false, + vsnip = false, + }, +}) vim.o.completeopt = "menuone,noselect" -- nvim-compe mappings -local compe_map_opts = {expr = true, noremap = true, silent = true} -vim.api.nvim_set_keymap('i', '<C-Space>', 'compe#complete()', compe_map_opts) -vim.api.nvim_set_keymap('i', '<CR>', "compe#confirm('<CR>')", compe_map_opts) -vim.api.nvim_set_keymap('i', '<ESC>', "compe#close('<ESC>')", compe_map_opts) -vim.api.nvim_set_keymap('i', '<C-f>', "compe#scroll({'delta': +4})", compe_map_opts) -vim.api.nvim_set_keymap('i', '<C-d>', "compe#scroll({'delta': -4})", compe_map_opts) +local compe_map_opts = { expr = true, noremap = true, silent = true } +vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", compe_map_opts) +vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", compe_map_opts) +vim.api.nvim_set_keymap("i", "<ESC>", "compe#close('<ESC>')", compe_map_opts) +vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({'delta': +4})", compe_map_opts) +vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({'delta': -4})", compe_map_opts) diff --git a/lua/config/indent-blankline.lua b/lua/config/indent-blankline.lua index 78cc8f9..6db2f72 100644 --- a/lua/config/indent-blankline.lua +++ b/lua/config/indent-blankline.lua @@ -1,2 +1,2 @@ -vim.g.indent_blankline_char = '│' -vim.g.indent_blankline_filetype_exclude = {'help', 'startify', 'git', 'markdown'} +vim.g.indent_blankline_char = "│" +vim.g.indent_blankline_filetype_exclude = { "help", "startify", "git", "markdown" } diff --git a/lua/config/iron.lua b/lua/config/iron.lua index 926fb6d..74d7046 100644 --- a/lua/config/iron.lua +++ b/lua/config/iron.lua @@ -1,7 +1,7 @@ -local iron = require('iron') -iron.core.set_config{ +local iron = require("iron") +iron.core.set_config({ preferred = { - python = 'ipython' + python = "ipython", }, - repl_open_cmd = 'vertical 120 split' -} + repl_open_cmd = "vertical 120 split", +}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 4279a6e..79f6091 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -3,39 +3,43 @@ local M = {} function M.show_line_diagnostics() local opts = { focusable = false, - close_events = {'BufLeave', 'CursorMoved', 'InsertEnter', 'FocusLost'} + close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, } vim.lsp.diagnostic.show_line_diagnostics(opts) end local custom_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + local function buf_set_keymap(...) + vim.api.nvim_buf_set_keymap(bufnr, ...) + end + local function buf_set_option(...) + vim.api.nvim_buf_set_option(bufnr, ...) + end - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. - local opts = { noremap=true, silent=true } - buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) - buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) - buf_set_keymap('n', '<C-]>', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) - buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) - buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) - buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) - buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) - buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) - buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) - buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) - buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) - buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) - buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) - buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) - buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts) - buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) - - vim.cmd [[ + local opts = { noremap = true, silent = true } + buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) + buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) + buf_set_keymap("n", "<C-]>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) + buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts) + buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) + buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) + buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts) + buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts) + buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts) + buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts) + buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) + buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) + buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts) + buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts) + buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts) + buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) + + vim.cmd([[ autocmd CursorHold <buffer> lua require('config.lsp').show_line_diagnostics() - ]] + ]]) -- Set some key bindings conditional on server capabilities if client.resolved_capabilities.document_formatting then @@ -59,8 +63,8 @@ local custom_attach = function(client, bufnr) ]]) end - local msg = string.format('Language server %s started!' , client.name) - vim.api.nvim_echo({{msg, 'MoreMsg'}, }, false, {}) + local msg = string.format("Language server %s started!", client.name) + vim.api.nvim_echo({ { msg, "MoreMsg" } }, false, {}) end local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -68,68 +72,68 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true local lspconfig = require("lspconfig") -lspconfig.pylsp.setup{ +lspconfig.pylsp.setup({ on_attach = custom_attach, settings = { pylsp = { plugins = { - pylint = {enabled = true, executable = "pylint"}, - pyflakes = {enabled = false}, - pycodestyle = {enabled = false}, - jedi_completion = {fuzzy = true}, - pyls_isort = {enabled = true}, - pylsp_mypy = {enabled = true} - } - } + pylint = { enabled = true, executable = "pylint" }, + pyflakes = { enabled = false }, + pycodestyle = { enabled = false }, + jedi_completion = { fuzzy = true }, + pyls_isort = { enabled = true }, + pylsp_mypy = { enabled = true }, + }, + }, }, flags = { debounce_text_changes = 200, - } -} + }, +}) -- lspconfig.pyright.setup{ -- on_attach = custom_attach, -- } -lspconfig.clangd.setup{ +lspconfig.clangd.setup({ on_attach = custom_attach, capabilities = capabilities, filetypes = { "c", "cpp", "cc" }, flags = { debounce_text_changes = 500, - } -} + }, +}) -- set up vim-language-server -lspconfig.vimls.setup{ +lspconfig.vimls.setup({ on_attach = custom_attach, flags = { debounce_text_changes = 500, - } -} + }, +}) -local sumneko_binary_path = vim.fn.exepath('lua-language-server') -if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= '' then - local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ':h:h:h') +local sumneko_binary_path = vim.fn.exepath("lua-language-server") +if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then + local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h") - local runtime_path = vim.split(package.path, ';') + local runtime_path = vim.split(package.path, ";") table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") - require'lspconfig'.sumneko_lua.setup { + require("lspconfig").sumneko_lua.setup({ on_attach = custom_attach, - cmd = {sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua"}; + cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua" }, settings = { Lua = { runtime = { -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', + version = "LuaJIT", -- Setup your lua path path = runtime_path, }, diagnostics = { -- Get the language server to recognize the `vim` global - globals = {'vim'}, + globals = { "vim" }, }, workspace = { -- Make the server aware of Neovim runtime files @@ -141,59 +145,54 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= '' then }, }, }, - } + }) end -- Change diagnostic signs. -vim.fn.sign_define('LspDiagnosticsSignError', { text = "✗", texthl = "LspDiagnosticsDefaultError" }) -vim.fn.sign_define('LspDiagnosticsSignWarning', { text = "!", texthl = "LspDiagnosticsDefaultWarning" }) -vim.fn.sign_define('LspDiagnosticsSignInformation', { text = "", texthl = "LspDiagnosticsDefaultInformation" }) -vim.fn.sign_define('LspDiagnosticsSignHint', { text = "", texthl = "LspDiagnosticsDefaultHint" }) +vim.fn.sign_define("LspDiagnosticsSignError", { text = "✗", texthl = "LspDiagnosticsDefaultError" }) +vim.fn.sign_define("LspDiagnosticsSignWarning", { text = "!", texthl = "LspDiagnosticsDefaultWarning" }) +vim.fn.sign_define("LspDiagnosticsSignInformation", { text = "", texthl = "LspDiagnosticsDefaultInformation" }) +vim.fn.sign_define("LspDiagnosticsSignHint", { text = "", texthl = "LspDiagnosticsDefaultHint" }) + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + underline = false, + virtual_text = false, + signs = true, + update_in_insert = false, +}) + +-- Refs: https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#show-source-in-diagnostics +vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _) + local uri = params.uri + local bufnr = vim.uri_to_bufnr(uri) + + if not bufnr then + return + end + + if not vim.api.nvim_buf_is_loaded(bufnr) then + return + end + + local diagnostics = params.diagnostics + for i, v in ipairs(diagnostics) do + diagnostics[i].message = string.format("%s: %s", v.source, v.message) + end + vim.lsp.diagnostic.save(diagnostics, bufnr, client_id) -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { + local config = { underline = false, virtual_text = false, signs = true, update_in_insert = false, } -) - --- Refs: https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#show-source-in-diagnostics -vim.lsp.handlers["textDocument/publishDiagnostics"] = - function(_, _, params, client_id, _) - local uri = params.uri - local bufnr = vim.uri_to_bufnr(uri) - - if not bufnr then - return - end - - if not vim.api.nvim_buf_is_loaded(bufnr) then - return - end - - local diagnostics = params.diagnostics - for i, v in ipairs(diagnostics) do - diagnostics[i].message = string.format("%s: %s", v.source, v.message) - end - vim.lsp.diagnostic.save(diagnostics, bufnr, client_id) - - local config = { - underline = false, - virtual_text = false, - signs = true, - update_in_insert = false, - } - vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config) - end + vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config) +end -- The following settings works with the bleeding edge neovim. -- See https://github.com/neovim/neovim/pull/13998. -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( - vim.lsp.handlers.hover, { - border = 'rounded' - } -) +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", +}) return M diff --git a/lua/config/neoscroll.lua b/lua/config/neoscroll.lua index 57e1ff9..45b7c08 100644 --- a/lua/config/neoscroll.lua +++ b/lua/config/neoscroll.lua @@ -1,21 +1,21 @@ -require('neoscroll').setup({ - easing_function = "quadratic", +require("neoscroll").setup({ + easing_function = "quadratic", }) local t = {} -- Syntax: t[keys] = {function, {function arguments}} -- Use the "sine" easing function -t['<C-u>'] = {'scroll', {'-vim.wo.scroll', 'true', '20', [['cubic']]}} -t['<C-d>'] = {'scroll', { 'vim.wo.scroll', 'true', '20', [['cubic']]}} +t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } } +t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } } -- Use the "circular" easing function -t['<C-b>'] = {'scroll', {'-vim.api.nvim_win_get_height(0)', 'true', '50', [['cubic']]}} -t['<C-f>'] = {'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '50', [['cubic']]}} +t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } } +t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } } -- Pass "nil" to disable the easing animation (constant scrolling speed) -t['<C-y>'] = {'scroll', {'-0.10', 'false', '100', nil}} -t['<C-e>'] = {'scroll', { '0.10', 'false', '100', nil}} +t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } } +t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } } -- When no easing function is provided the default easing function (in this case "quadratic") will be used -t['zt'] = {'zt', {'10'}} -t['zz'] = {'zz', {'10'}} -t['zb'] = {'zb', {'10'}} +t["zt"] = { "zt", { "10" } } +t["zz"] = { "zz", { "10" } } +t["zb"] = { "zb", { "10" } } -require('neoscroll.config').set_mappings(t) +require("neoscroll.config").set_mappings(t) diff --git a/lua/config/nvim-bufferline.lua b/lua/config/nvim-bufferline.lua index 8697030..772287c 100644 --- a/lua/config/nvim-bufferline.lua +++ b/lua/config/nvim-bufferline.lua @@ -1,4 +1,4 @@ -require('bufferline').setup { +require("bufferline").setup({ options = { numbers = "buffer_id", number_style = "superscript", @@ -7,12 +7,12 @@ require('bufferline').setup { right_mouse_command = nil, left_mouse_command = "buffer %d", middle_mouse_command = nil, - indicator_icon = '▎', - buffer_close_icon = '', - modified_icon = '●', - close_icon = '', - left_trunc_marker = '', - right_trunc_marker = '', + indicator_icon = "▎", + buffer_close_icon = "", + modified_icon = "●", + close_icon = "", + left_trunc_marker = "", + right_trunc_marker = "", max_name_length = 18, max_prefix_length = 15, tab_size = 10, @@ -22,7 +22,7 @@ require('bufferline').setup { -- buffer will be hidden. -- filter out filetypes you don't want to see - local exclude_ft = {'qf', 'fugitive', 'git'} + local exclude_ft = { "qf", "fugitive", "git" } local cur_ft = vim.bo[bufnr].filetype local should_filter = vim.tbl_contains(exclude_ft, cur_ft) @@ -40,6 +40,6 @@ require('bufferline').setup { separator_style = "slant", enforce_regular_tabs = false, always_show_bufferline = true, - sort_by = 'id' - } -} + sort_by = "id", + }, +}) diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua index a6ac7f7..574b763 100644 --- a/lua/config/treesitter.lua +++ b/lua/config/treesitter.lua @@ -1,8 +1,8 @@ -require'nvim-treesitter.configs'.setup { - ensure_installed = {'python', 'cpp', 'lua'}, - ignore_install = {}, -- List of parsers to ignore installing +require("nvim-treesitter.configs").setup({ + ensure_installed = { "python", "cpp", "lua" }, + ignore_install = {}, -- List of parsers to ignore installing highlight = { - enable = true, -- false will disable the whole extension - disable = {}, -- list of language that will be disabled + enable = true, -- false will disable the whole extension + disable = {}, -- list of language that will be disabled }, -} +}) |
