Skip to content

Commit f3e62ad

Browse files
committed
move more plugins to lazy config
1 parent 5a7e2f4 commit f3e62ad

File tree

9 files changed

+310
-49
lines changed

9 files changed

+310
-49
lines changed

config/nvim/init.vim

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
lua require 'init'
22

3-
filetype off " required
4-
53
set rtp +=~/.config/nvim
64

75
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -15,6 +13,7 @@ set rtp+=/usr/local/opt/fzf
1513

1614
" Enable filetype detection
1715
filetype plugin indent on
16+
filetype indent on
1817

1918
" Restore cursor position in irb
2019
au BufReadPost *
@@ -42,13 +41,6 @@ augroup SpellCheck
4241
augroup END
4342
set complete+=kspell
4443

45-
" Use Endwise for Ruby, manually add mapping here to avoid COC conflict
46-
let g:endwise_no_mappings = 1
47-
augroup vimrc-ruby-settings
48-
autocmd!
49-
autocmd FileType ruby imap <expr> <CR> pumvisible() ? "\<C-Y>\<Plug>DiscretionaryEnd" : "\<CR>\<Plug>DiscretionaryEnd"
50-
augroup END
51-
5244
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
5345
" UI
5446
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -84,17 +76,8 @@ else
8476
set term=screen-256color
8577
endif
8678

87-
"colorscheme kolor
88-
"colorscheme palenight
89-
let g:palenight_terminal_italics=1
9079
set guifont=Monaco:h12
9180

92-
"augroup ColorsForFileTypes " Map file extensions to the proper filetype
93-
" au!
94-
" au FileType typescript colorscheme Tomorrow-Night-Eighties
95-
"augroup END
96-
97-
9881
syntax on " Enable syntax highlighting
9982
"set rnu " Use relative line numbers
10083
"set number " Display the current line number
@@ -189,8 +172,8 @@ nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
189172
inoremap <C-j> <ESC>:m .+1<CR>==gi
190173
inoremap <C-k> <ESC>:m .-2<CR>==gi
191174
" Visual mode
192-
vnoremap <C-j> :m '>+1<CR>gv=gv
193-
vnoremap <C-k> :m '<-2<CR>gv=gv
175+
xnoremap <C-j> :m '>+1<CR>gv=gv
176+
xnoremap <C-k> :m '<-2<CR>gv=gv
194177
" Normal mode
195178
"nnoremap <C-j> :m .+1<CR>==
196179
"nnoremap <C-k> :m .-2<CR>==
@@ -205,7 +188,7 @@ noremap tp "+p
205188
noremap tP "+P
206189
207190
" Remove a buffer, keep split
208-
nnoremap <Leader>d :bp\|bd #<CR>
191+
nnoremap <leader>d :bp\|bd #<CR>
209192
210193
" Fast switch to alternate file
211194
nnoremap <BS> <C-^>

config/nvim/lua/_autopairs.lua

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
local vim = vim
22

3-
local npairs = require("nvim-autopairs")
4-
npairs.setup()
5-
6-
-- clear all rule if you don"t want to use autopairs
7-
--npairs.clear_rules()
8-
local endwise = require("nvim-autopairs.ts-rule").endwise
9-
10-
npairs.add_rules({
11-
-- then$ is a lua regex
12-
-- end is a match pair
13-
-- lua is a filetype
14-
-- if_statement is a treesitter name. set it = nil to skip check with treesitter
15-
endwise("then$", "end", "lua", "if_statement"),
16-
})
17-
18-
19-
local remap = vim.api.nvim_set_keymap
203
-- skip it, if you use another global object
214
_G.MUtils = {}
225

236
vim.g.completion_confirm_key = ""
247
MUtils.completion_confirm = function()
8+
local npairs = require("nvim-autopairs")
259
if vim.fn.pumvisible() ~= 0 then
2610
if vim.fn.complete_info()["selected"] ~= -1 then
2711
return vim.fn["compe#confirm"](npairs.esc("<cr>"))
@@ -34,4 +18,4 @@ MUtils.completion_confirm = function()
3418
end
3519

3620

37-
remap("i", "<CR>", "v:lua.MUtils.completion_confirm()", { expr = true, noremap = true })
21+
-- vim.api.nvim_set_keymap("i", "<CR>", "v:lua.MUtils.completion_confirm()", { expr = true, noremap = true })

config/nvim/lua/plugins/completion.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ return {
5656
completion = cmp.config.window.bordered(),
5757
documentation = cmp.config.window.bordered(),
5858
},
59-
6059
formatting = {
6160
format = function(entry, vim_item)
6261
if vim.tbl_contains({ 'path' }, entry.source.name) then

config/nvim/lua/plugins/github.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local vim = vim
2+
3+
return {
4+
"pwntester/octo.nvim",
5+
dependencies = {
6+
"nvim-lua/plenary.nvim",
7+
"nvim-telescope/telescope.nvim",
8+
"nvim-tree/nvim-web-devicons",
9+
},
10+
cmd = {
11+
"Octo"
12+
},
13+
keys = {
14+
{ "<leader>pr", "<CMD>Octo pr list<CR>" }
15+
},
16+
opts = {},
17+
init = function()
18+
vim.treesitter.language.register('markdown', 'octo')
19+
end,
20+
}

config/nvim/lua/plugins/init.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ local vim = vim
33
return {
44
{ "RRethy/vim-illuminate" }, -- repeated word highlighting
55
{ "tommcdo/vim-exchange" },
6-
{ "tpope/vim-endwise" },
76
{ "tpope/vim-fugitive" },
87
{ "tpope/vim-surround" },
98
{ "tpope/vim-unimpaired" },
@@ -17,7 +16,16 @@ return {
1716

1817
{
1918
"windwp/nvim-autopairs",
20-
init = function() require("_autopairs") end
19+
event = "InsertEnter",
20+
opts = {},
21+
-- init = function() require("_autopairs") end
22+
},
23+
{
24+
'altermo/ultimate-autopair.nvim',
25+
enabled = false,
26+
event = { 'InsertEnter', 'CmdlineEnter' },
27+
branch = 'v0.6', --recommended as each new version will have breaking changes
28+
opts = {},
2129
},
2230

2331
-- git signs in the gutter
@@ -46,6 +54,7 @@ return {
4654
}
4755

4856

57+
-- Graveyard??
4958
-- use {
5059
-- "catppuccin/nvim",
5160
-- as = "catppuccin",
@@ -63,12 +72,6 @@ return {
6372
-- end,
6473
-- }
6574

66-
-- use {
67-
-- 'Exafunction/codeium.vim',
68-
-- config = function() require("_codeium") end
69-
-- }
70-
71-
-- Graveyard??
7275
-- use "easymotion/vim-easymotion"
7376
-- use "andymass/vim-matchup"
7477
-- use "tpope/vim-dispatch"
@@ -81,3 +84,4 @@ return {
8184
-- { "jgdavey/vim-blockle" }, -- Ruby block syntax toggling
8285
-- { "kana/vim-textobj-user" }, -- Ruby block awareness: ar/ir
8386
-- { "nelstrom/vim-textobj-rubyblock" }, -- Ruby block awareness: ar/ir
87+
-- { "tpope/vim-endwise" },

config/nvim/lua/plugins/lsp.lua

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
local config = function()
2+
local vim = vim
3+
local nvim_lsp = require('lspconfig')
4+
5+
-- Set up completion lspconfig.
6+
local capabilities = require('cmp_nvim_lsp').default_capabilities()
7+
8+
9+
-- Use an on_attach function to only map the following keys
10+
-- after the language server attaches to the current buffer
11+
local on_attach = function(client, bufnr)
12+
-- https://github.com/redhat-developer/yaml-language-server/issues/486#issuecomment-1046792026
13+
-- if client.name == "yamlls" then
14+
-- client.server_capabilities.documentFormattingProvider = true
15+
-- end
16+
17+
-- Enable completion triggered by <c-x><c-o>
18+
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
19+
20+
-- Mappings.
21+
-- See `:help vim.lsp.*` for documentation on any of the below functions
22+
local bufopts = { noremap = true, silent = true, buffer = bufnr }
23+
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
24+
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
25+
vim.keymap.set('n', 'L', vim.lsp.buf.hover, bufopts)
26+
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
27+
vim.keymap.set('n', '<C-s>', vim.lsp.buf.signature_help, bufopts)
28+
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
29+
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
30+
vim.keymap.set('n', '<space>wl', function()
31+
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
32+
end, bufopts)
33+
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
34+
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
35+
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
36+
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
37+
-- vim.keymap.set('n', '[d', vim.lsp.diagnostic.goto_prev, bufopts)
38+
-- vim.keymap.set('n', ']d', vim.lsp.diagnostic.goto_next, bufopts)
39+
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
40+
41+
-- Format on save
42+
-- vim.api.nvim_create_autocmd("BufWritePre", {
43+
-- buffer = buffer,
44+
-- callback = function()
45+
-- if client.server_capabilities.documentFormattingProvider then
46+
-- vim.lsp.buf.format { async = false }
47+
-- end
48+
-- end
49+
-- })
50+
end
51+
52+
local servers = {
53+
"bashls",
54+
"dockerls",
55+
"gopls",
56+
"html",
57+
"jsonls",
58+
"lua_ls",
59+
"sourcekit",
60+
"taplo",
61+
"ts_ls",
62+
-- "yamlls",
63+
"marksman",
64+
-- "graphql",
65+
}
66+
for _, lsp in ipairs(servers) do
67+
nvim_lsp[lsp].setup { on_attach = on_attach, capabilities = capabilities }
68+
end
69+
70+
require('lspconfig').rust_analyzer.setup {
71+
capabilities = capabilities,
72+
on_attach = on_attach,
73+
-- cmd = { "rustup", "run", "nightly", "rust-analyzer" },
74+
settings = {
75+
['rust-analyzer'] = {
76+
check = {
77+
-- allFeatures = true,
78+
disabled = { "unresolved-proc-macro" },
79+
overrideCommand = {
80+
'cargo', 'clippy', '--workspace', '--message-format=json', '--all-targets', '--all-features'
81+
}
82+
}
83+
}
84+
}
85+
}
86+
87+
-- Ruby
88+
require('lspconfig').solargraph.setup({
89+
capabilities = capabilities,
90+
on_attach = on_attach,
91+
settings = {
92+
solargraph = {
93+
completion = true,
94+
definitions = true,
95+
diagnostics = true,
96+
formatting = true,
97+
hover = true,
98+
references = true,
99+
rename = true,
100+
},
101+
},
102+
})
103+
104+
-- Elixir
105+
require 'lspconfig'.elixirls.setup {
106+
capabilities = capabilities,
107+
on_attach = on_attach,
108+
cmd = { "elixir-ls" },
109+
}
110+
-- Python
111+
local home = os.getenv("HOME")
112+
local util = require('lspconfig').util
113+
require('lspconfig').pyright.setup({
114+
capabilities = capabilities,
115+
on_attach = on_attach,
116+
cmd = { "pyright-langserver", "--stdio", "--verbose" },
117+
-- rootMarkers = { "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json", ".git" },
118+
119+
-- root_dir = vim.fs.dirname(vim.fs.find('.git', { path = root_dir, upward = true })[1]),
120+
121+
root_dir = util.root_pattern(".git/", "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile",
122+
"pyrightconfig.json"),
123+
settings = {
124+
-- rootMarkers = { ".git/" },
125+
-- rootMarkers = { ".git/", "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json", },
126+
python = {
127+
analysis = {
128+
pythonPath = home .. "/.pyenv/shims/python"
129+
},
130+
},
131+
},
132+
})
133+
134+
135+
require('lspconfig').ruff.setup({
136+
init_options = { documentFormatting = true },
137+
capabilities = capabilities,
138+
on_attach = on_attach,
139+
})
140+
141+
142+
local shfmt = {
143+
formatCommand = "shfmt -ci -s -bn -i 2",
144+
formatStdin = true,
145+
}
146+
147+
148+
--https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/init.lua
149+
require("lspconfig").efm.setup {
150+
capabilities = capabilities,
151+
on_attach = on_attach,
152+
init_options = { documentFormatting = true },
153+
root_dir = vim.loop.cwd,
154+
settings = {
155+
rootMarkers = { ".git/" },
156+
languages = {
157+
zsh = { shfmt },
158+
bash = { shfmt },
159+
sh = { shfmt },
160+
}
161+
},
162+
filetypes = { 'zsh', 'sh', 'bash' }
163+
}
164+
165+
require("lspconfig").jdtls.setup {
166+
capabilities = capabilities,
167+
on_attach = on_attach,
168+
cmd = { "/opt/homebrew/bin/jdtls", "--java-executable", "/opt/homebrew/opt/openjdk/bin/java", },
169+
}
170+
171+
172+
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
173+
vim.lsp.diagnostic.on_publish_diagnostics, {
174+
underline = true,
175+
176+
-- Enable/Disable virtual text diagnostics
177+
virtual_text = true,
178+
179+
signs = true,
180+
update_in_insert = false,
181+
}
182+
)
183+
184+
vim.fn.sign_define("LspDiagnosticsSignError", { text = "!!" })
185+
vim.fn.sign_define("LspDiagnosticsSignWarning", { text = "" })
186+
vim.fn.sign_define("LspDiagnosticsSignInformation", { text = "*" })
187+
vim.fn.sign_define("LspDiagnosticsSignHint", { text = "" })
188+
189+
190+
-- match the active buffer background color from _colors
191+
vim.cmd [[autocmd! ColorScheme * highlight NormalFloat guibg=#2E373D guifg=white]]
192+
vim.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#2E373D]]
193+
194+
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
195+
border = "rounded",
196+
})
197+
end
198+
199+
return {
200+
{
201+
"neovim/nvim-lspconfig",
202+
dependencies = {
203+
{ "hrsh7th/cmp-nvim-lsp" },
204+
{ "nvim-lua/lsp_extensions.nvim" },
205+
},
206+
config = config
207+
}
208+
}

0 commit comments

Comments
 (0)