require('gitsigns').setup() require('mini.statusline').setup({ content = { active = function() local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) local git = MiniStatusline.section_git({ trunc_width = 75, icon = '' }) local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75, icon = '' }) local filename = MiniStatusline.section_filename({ trunc_width = 140 }) local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 }) local location = MiniStatusline.section_location({ trunc_width = 75 }) return MiniStatusline.combine_groups({ { hl = mode_hl, strings = { mode } }, { hl = 'MiniStatuslineDevinfo', strings = { git, diagnostics } }, '%<', -- Mark general truncate point { hl = 'MiniStatuslineFilename', strings = { filename } }, '%=', -- End left alignment { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } }, { hl = mode_hl, strings = { location } }, }) end }, }) require('mini.bufremove').setup() require('mini.indentscope').setup() require('nvim-treesitter.configs').setup { highlight = { enable = true, }, } local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) opts = opts or {} opts.border = opts.border or 'single' return orig_util_open_floating_preview(contents, syntax, opts, ...) end vim.diagnostic.config({ virtual_text = { severity = { min = vim.diagnostic.severity.WARN } } }) local opts = { noremap=true, silent=true } vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setqflist({ severity = { min = vim.diagnostic.severity.WARN } })', opts) vim.api.nvim_set_keymap('n', 'q', 'lua MiniBufremove.delete()', opts) -- Allow pressing enter to autocomplete vim.api.nvim_set_keymap('i', '', 'pumvisible() ? "\\" : "\\"', { noremap = true, expr = true }) function on_attach(client, bufnr) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.MiniCompletion.completefunc_lsp') -- Mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) end require'nvim-treesitter.configs'.setup { highlight = { enable = true, }, } require('mini.completion').setup({ delay = { -- disable autocomplete completion = 100000000, info = 100, signature = 50, }, lsp_completion = { source_func = 'omnifunc', auto_setup = false, }, }); local nvim_lsp = require('lspconfig') local null_ls = require('null-ls') local null_ls_sources = {} if vim.fn.executable("node_modules/.bin/eslint") == 1 then table.insert(null_ls_sources, null_ls.builtins.formatting.eslint_d) table.insert(null_ls_sources, null_ls.builtins.diagnostics.eslint_d) table.insert(null_ls_sources, null_ls.builtins.code_actions.eslint_d) end if vim.fn.executable("gofmt") == 1 then table.insert(null_ls_sources, null_ls.builtins.formatting.gofmt) end if vim.fn.executable("shellcheck") == 1 then table.insert(null_ls_sources, null_ls.builtins.diagnostics.shellcheck) table.insert(null_ls_sources, null_ls.builtins.code_actions.shellcheck) end if vim.fn.executable("deno") == 1 then nvim_lsp.denols.setup({ capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()), on_attach = on_attach, }); table.insert(null_ls_sources, null_ls.builtins.formatting.deno_fmt); end if vim.fn.executable("node_modules/.bin/tsc") == 1 then local ts_utils = require("nvim-lsp-ts-utils") nvim_lsp.tsserver.setup({ init_options = ts_utils.init_options, flags = { debounce_text_changes = 150, }, on_attach = function(client, bufnr) client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_range_formatting = false on_attach(client, bufnr) ts_utils.setup({ debug = false, disable_commands = false, enable_import_on_completion = true, -- import all import_all_timeout = 5000, -- ms -- lower numbers = higher priority import_all_priorities = { same_file = 1, -- add to existing import statement local_files = 2, -- git files or files with relative path markers buffer_content = 3, -- loaded buffer content buffers = 4, -- loaded buffer names }, import_all_scan_buffers = 100, import_all_select_source = false, -- filter diagnostics filter_out_diagnostics_by_severity = {}, filter_out_diagnostics_by_code = {}, -- inlay hints auto_inlay_hints = false, inlay_hints_highlight = "Comment", -- update imports on file move update_imports_on_move = false, require_confirmation_on_move = false, watch_dir = nil, }) -- required to fix code action ranges and filter diagnostics ts_utils.setup_client(client) end, }) end null_ls.setup({ sources = null_ls_sources, on_attach = function(client, bufnr) if client.resolved_capabilities.document_formatting then vim.cmd([[ augroup LspFormatting autocmd! * autocmd BufWritePre lua vim.lsp.buf.formatting_sync() augroup END ]]) end end, });