123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- 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', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
- vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
- vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
- vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setqflist({ severity = { min = vim.diagnostic.severity.WARN } })<CR>', opts)
- vim.api.nvim_set_keymap('n', '<Leader>q', '<cmd>lua MiniBufremove.delete()<CR>', opts)
- -- Allow pressing enter to autocomplete
- vim.api.nvim_set_keymap('i', '<CR>', 'pumvisible() ? "\\<C-y>" : "\\<CR>"', { noremap = true, expr = true })
- function on_attach(client, bufnr)
- -- Enable completion triggered by <c-x><c-o>
- 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', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', 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 = true,
- 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! * <buffer>
- autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
- augroup END
- ]])
- end
- end,
- });
|