Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Jan 11, 2025
1 parent abdd6ef commit c8ff397
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 73 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions after/ftplugin/lua.lua
Original file line number Diff line number Diff line change
@@ -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 <buffer> lo local
inoreabbrev <buffer> lf local function()<left><left>
inoreabbrev <buffer> fu function() end<left><left><left><left>
inoreabbrev <buffer> fo (''):format()<left><left><s-left><left><left><left>
]])
1 change: 1 addition & 0 deletions colors/solarized.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
45 changes: 22 additions & 23 deletions lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
43 changes: 24 additions & 19 deletions lua/internal/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions lua/internal/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ au('LspDetach', {
})

au('InsertLeave', {
group = group,
callback = function()
if vim.fn.executable('iswitch') == 0 then
return
Expand All @@ -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('<Cmd>nohl<CR>', 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)
Expand Down
21 changes: 1 addition & 20 deletions lua/keymap/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ map.n({
['gp'] = cmd('Lspsaga goto_definition'),
['gh'] = cmd('Lspsaga finder'),
['<Leader>o'] = cmd('Lspsaga outline'),
['<Leader>dw'] = cmd('Lspsaga show_workspace_diagnostics'),
['<Leader>db'] = cmd('Lspsaga show_buf_diagnostics'),
['<Leader>d'] = cmd('Dired'),
-- dbsession
['<Leader>ss'] = cmd('SessionSave'),
['<Leader>sl'] = cmd('SessionLoad'),
Expand Down Expand Up @@ -59,21 +58,3 @@ end, { expr = true })
map.nt('<A-d>', cmd('Lspsaga term_toggle'))

map.nx('ga', cmd('Lspsaga code_action'))

local loaded_netrw = false
-- keymap see internal/event.lua
map.n('<leader>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)
3 changes: 2 additions & 1 deletion lua/modules/lsp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ lspconfig.rust_analyzer.setup({
})

local servers = {
'basedpyright',
-- 'basedpyright',
'pyright',
'bashls',
'zls',
'cmake',
Expand Down
11 changes: 1 addition & 10 deletions lua/modules/tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@ function config.guard()

ft('lua'):fmt({
cmd = 'stylua',
args = { '--stdin-filepath', './dummy', '-' },
args = { '-' },
stdin = true,
ignore_patterns = 'function.*_spec%.lua',
find = '.stylua.toml',
})
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
6 changes: 6 additions & 0 deletions lua/modules/ui/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ packadd({
config = conf.gitsigns,
})

packadd({
'nvimdev/dired.nvim',
dev = true,
cmd = 'Dired',
})

packadd({
'nvimdev/indentmini.nvim',
event = 'BufEnter */*',
Expand Down

0 comments on commit c8ff397

Please sign in to comment.