diff --git a/README.md b/README.md index 78e59d8c..94544452 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +Word + **Text Editor just text editor Please dont't do no more** ![QQ20240623-203745](https://github.com/glepnir/nvim/assets/41671631/5f849fa8-9c4d-4cb4-99e2-2dc21029cb4f) diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua new file mode 100644 index 00000000..6a5f7b8e --- /dev/null +++ b/after/ftplugin/lua.lua @@ -0,0 +1,10 @@ +vim.cmd([[ +" From https://github.com/tpope/tpope/blob/master/.vimrc +setlocal includeexpr=substitute(v:fname,'\\.','/','g').'.lua' +setlocal comments-=:-- comments+=:---,:-- + +inoreabbrev lo local +inoreabbrev lf local function() +inoreabbrev fu function() end +inoreabbrev fo (''):format() +]]) diff --git a/colors/solarized.lua b/colors/solarized.lua index bc0580d3..b4bbfa74 100644 --- a/colors/solarized.lua +++ b/colors/solarized.lua @@ -133,6 +133,7 @@ local function load_solarized() shl('GitSignsDelete', { fg = colors.red, bg = colors.base03 }) shl('DashboardHeader', { fg = colors.green }) shl('ModeLineMode', { bold = true }) + shl('ModeLinefileinfo', { bold = true }) end load_solarized() diff --git a/lua/core/options.lua b/lua/core/options.lua index 81efb6bb..a1bb49ea 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -2,8 +2,8 @@ local opt = vim.opt opt.hidden = true opt.magic = true -opt.virtualedit = "block" -opt.clipboard = "unnamedplus" +opt.virtualedit = 'block' +opt.clipboard = 'unnamedplus' opt.wildignorecase = true opt.swapfile = false @@ -13,15 +13,14 @@ opt.ttimeout = true opt.timeoutlen = 500 opt.ttimeoutlen = 10 opt.updatetime = 100 -opt.redrawtime = 1500 opt.ignorecase = true opt.smartcase = true opt.infercase = true opt.cursorline = true -opt.completeopt = "menu,menuone,noinsert,fuzzy,popup" +opt.completeopt = 'menu,menuone,noinsert,fuzzy,popup' opt.showmode = false -opt.shortmess = "aoOTIcF" +opt.shortmess = 'aoOTIcF' opt.scrolloff = 2 opt.sidescrolloff = 5 opt.ruler = false @@ -34,7 +33,7 @@ opt.laststatus = 3 opt.list = true --eol:¬ -opt.listchars = "tab:» ,nbsp:+,trail:·,extends:→,precedes:←," +opt.listchars = 'tab:» ,nbsp:+,trail:·,extends:→,precedes:←,' opt.undofile = true opt.smarttab = true @@ -44,29 +43,29 @@ opt.tabstop = 2 opt.shiftwidth = 2 opt.foldlevelstart = 99 -opt.foldmethod = "marker" +opt.foldmethod = 'marker' opt.splitright = true opt.wrap = false opt.number = true -opt.signcolumn = "yes" -opt.spelloptions = "camel" +opt.signcolumn = 'yes' +opt.spelloptions = 'camel' opt.textwidth = 80 -opt.colorcolumn = "+0" +opt.colorcolumn = '+0' -if vim.uv.os_uname().sysname == "Darwin" then - vim.g.clipboard = { - name = "macOS-clipboard", - copy = { - ["+"] = "pbcopy", - ["*"] = "pbcopy", - }, - paste = { - ["+"] = "pbpaste", - ["*"] = "pbpaste", - }, - cache_enabled = 0, - } +if vim.uv.os_uname().sysname == 'Darwin' then + vim.g.clipboard = { + name = 'macOS-clipboard', + copy = { + ['+'] = 'pbcopy', + ['*'] = 'pbcopy', + }, + paste = { + ['+'] = 'pbpaste', + ['*'] = 'pbpaste', + }, + cache_enabled = 0, + } end diff --git a/lua/internal/completion.lua b/lua/internal/completion.lua index 36112dc8..503361dc 100644 --- a/lua/internal/completion.lua +++ b/lua/internal/completion.lua @@ -8,11 +8,13 @@ ffi.cdef([[ bool pum_visible(void); ]]) local pumvisible = libc.pum_visible +local g = api.nvim_create_augroup('glepnir/completion', { clear = true }) -- completion on word which not exist in lsp client triggerCharacters local function auto_trigger(bufnr, client) au(InsertCharPre, { buffer = bufnr, + group = g, callback = function() if pumvisible() then return @@ -30,6 +32,28 @@ local function auto_trigger(bufnr, client) }) end +au('LspAttach', { + group = g, + callback = function(args) + local bufnr = args.buf + local client = lsp.get_client_by_id(args.data.client_id) + if not client or not client:supports_method('textDocument/completion') then + return + end + + completion.enable(true, client.id, bufnr, { + autotrigger = true, + convert = function(item) + return { abbr = item.label:gsub('%b()', ''), kind = '', kind_hlgroup = '' } + end, + }) + + if #api.nvim_get_autocmds({ buffer = bufnr, event = 'InsertCharPre', group = g }) == 0 then + auto_trigger(bufnr, client) + end + end, +}) + local function set_popup(bufnr) au('CompleteChanged', { buffer = bufnr, @@ -48,25 +72,6 @@ local function set_popup(bufnr) }) end -au('LspAttach', { - callback = function(args) - local bufnr = args.buf - local client = lsp.get_client_by_id(args.data.client_id) - if not client or not client:supports_method('textDocument/completion') then - return - end - - completion.enable(true, client.id, bufnr, { - autotrigger = true, - convert = function(item) - return { abbr = item.label:gsub('%b()', ''), kind = '' } - end, - }) - auto_trigger(bufnr, client) - -- set_popup(bufnr) - end, -}) - local function feedkeys(key) api.nvim_feedkeys(api.nvim_replace_termcodes(key, true, false, true), 'n', true) end diff --git a/lua/internal/event.lua b/lua/internal/event.lua index 6ad2b7d4..c636538f 100644 --- a/lua/internal/event.lua +++ b/lua/internal/event.lua @@ -104,6 +104,7 @@ au('LspDetach', { }) au('InsertLeave', { + group = group, callback = function() if vim.fn.executable('iswitch') == 0 then return @@ -117,7 +118,28 @@ au('InsertLeave', { desc = 'auto switch to abc input', }) +au('CmdlineLeave', { + group = group, + once = true, + callback = function() + if vim.v.event.cmdtype ~= '/' then + return + end + au({ 'InsertEnter', 'CursorHold' }, { + group = group, + callback = function() + if vim.v.hlsearch == 0 then + return + end + local keycode = api.nvim_replace_termcodes('nohl', true, false, true) + api.nvim_feedkeys(keycode, 'n', false) + end, + }) + end, +}) + au('FileType', { + group = group, pattern = 'netrw', callback = function() local map = function(lhs, rhs, remap, desc) diff --git a/lua/keymap/init.lua b/lua/keymap/init.lua index 85a679c5..ceb15530 100644 --- a/lua/keymap/init.lua +++ b/lua/keymap/init.lua @@ -13,8 +13,7 @@ map.n({ ['gp'] = cmd('Lspsaga goto_definition'), ['gh'] = cmd('Lspsaga finder'), ['o'] = cmd('Lspsaga outline'), - ['dw'] = cmd('Lspsaga show_workspace_diagnostics'), - ['db'] = cmd('Lspsaga show_buf_diagnostics'), + ['d'] = cmd('Dired'), -- dbsession ['ss'] = cmd('SessionSave'), ['sl'] = cmd('SessionLoad'), @@ -59,21 +58,3 @@ end, { expr = true }) map.nt('', cmd('Lspsaga term_toggle')) map.nx('ga', cmd('Lspsaga code_action')) - -local loaded_netrw = false --- keymap see internal/event.lua -map.n('n', function() - if not loaded_netrw then - vim.g.loaded_netrwPlugin = nil - vim.g.netrw_keepdir = 0 - vim.g.netrw_winsize = math.floor((30 / vim.o.columns) * 100) - vim.g.netrw_banner = 0 - vim.g.netrw_list_hide = [[\(^\|\s\s\)\zs\.\S\+]] - vim.g.netrw_liststyle = 3 - vim.cmd.source(vim.env.VIMRUNTIME .. '/plugin/netrwPlugin.vim') - vim.cmd('Lexplore %:p:h') - loaded_netrw = true - return - end - vim.cmd('Lexplore %:p:h') -end) diff --git a/lua/modules/lsp/config.lua b/lua/modules/lsp/config.lua index 9b464615..58b97226 100644 --- a/lua/modules/lsp/config.lua +++ b/lua/modules/lsp/config.lua @@ -82,7 +82,8 @@ lspconfig.rust_analyzer.setup({ }) local servers = { - 'basedpyright', + -- 'basedpyright', + 'pyright', 'bashls', 'zls', 'cmake', diff --git a/lua/modules/tools/config.lua b/lua/modules/tools/config.lua index 3b67a656..8406ae25 100644 --- a/lua/modules/tools/config.lua +++ b/lua/modules/tools/config.lua @@ -18,7 +18,7 @@ function config.guard() ft('lua'):fmt({ cmd = 'stylua', - args = { '--stdin-filepath', './dummy', '-' }, + args = { '-' }, stdin = true, ignore_patterns = 'function.*_spec%.lua', find = '.stylua.toml', @@ -26,15 +26,6 @@ function config.guard() ft('go'):fmt('lsp'):append('golines') ft('rust'):fmt('rustfmt') ft('typescript', 'javascript', 'typescriptreact', 'javascriptreact'):fmt('prettier') - -- hack when save diagnostic is missing - vim.api.nvim_create_autocmd('User', { - pattern = 'GuardFmt', - callback = function(args) - if args.data.status == 'done' then - vim.diagnostic.show() - end - end, - }) end return config diff --git a/lua/modules/ui/package.lua b/lua/modules/ui/package.lua index bcf9a9da..a93c0609 100644 --- a/lua/modules/ui/package.lua +++ b/lua/modules/ui/package.lua @@ -20,6 +20,12 @@ packadd({ config = conf.gitsigns, }) +packadd({ + 'nvimdev/dired.nvim', + dev = true, + cmd = 'Dired', +}) + packadd({ 'nvimdev/indentmini.nvim', event = 'BufEnter */*',