Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dfa3afd00 | |||
| cad392fab5 | |||
| 34e273b305 | |||
| d490e3aa45 | |||
| a4468aa339 | |||
| e099c4c688 | |||
| 7ab1449943 | |||
| b8e245dede | |||
| d9249a54f1 |
15
lua/config/comment.lua
Normal file
15
lua/config/comment.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
require("Comment").setup({
|
||||||
|
mappings = {
|
||||||
|
---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`
|
||||||
|
basic = false,
|
||||||
|
---Extra mapping; `gco`, `gcO`, `gcA`
|
||||||
|
extra = false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>/", require("Comment.api").toggle.linewise.current)
|
||||||
|
|
||||||
|
vim.keymap.set("v", "<leader>/",
|
||||||
|
'<ESC><CMD>lua require("Comment.api").toggle.linewise(vim.fn.visualmode())<CR>', opts)
|
||||||
@@ -2,3 +2,4 @@ require("config.lazy")
|
|||||||
require("config.lsp")
|
require("config.lsp")
|
||||||
require("config.theme")
|
require("config.theme")
|
||||||
require("config.nvim-tree")
|
require("config.nvim-tree")
|
||||||
|
require("config.comment")
|
||||||
|
|||||||
@@ -5,21 +5,35 @@ require("lazy").setup({
|
|||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
-- Code snippet engine
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
version = "v2.*",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"windwp/nvim-autopairs",
|
||||||
|
opts = {
|
||||||
|
fast_wrap = {},
|
||||||
|
disable_filetype = { "TelescopePrompt", "vim" },
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("nvim-autopairs").setup(opts)
|
||||||
|
|
||||||
|
-- setup cmp for autopairs
|
||||||
|
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||||
|
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
||||||
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
||||||
"hrsh7th/cmp-path", -- path auto-completion
|
"hrsh7th/cmp-path", -- path auto-completion
|
||||||
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
|
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("config.nvim-cmp")
|
require("config.nvim-cmp")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
-- Code snippet engine
|
|
||||||
{
|
|
||||||
"L3MON4D3/LuaSnip",
|
|
||||||
version = "v2.*",
|
|
||||||
},
|
|
||||||
|
|
||||||
-- LSP manager
|
-- LSP manager
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
@@ -39,4 +53,6 @@ require("lazy").setup({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"numToStr/Comment.nvim",
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ require('mason').setup({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local servers = { 'pylsp', 'lua_ls', 'rust_analyzer', 'zls' }
|
local servers = { 'lua_ls', 'rust_analyzer', 'nil_ls' }
|
||||||
|
local l_servers = { 'clangd', 'zls'}
|
||||||
|
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
-- A list of servers to automatically install if they're not already installed
|
-- A list of servers to automatically install if they're not already installed
|
||||||
@@ -33,10 +34,10 @@ local lspconfig = require('lspconfig')
|
|||||||
-- Customized on_attach function
|
-- Customized on_attach function
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
vim.keymap.set('n', 'd', vim.diagnostic.open_float, opts)
|
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set('n', 'dn', vim.diagnostic.goto_prev, opts)
|
vim.keymap.set('n', '<leader>dp', vim.diagnostic.goto_prev, opts)
|
||||||
vim.keymap.set('n', 'dp', vim.diagnostic.goto_next, opts)
|
vim.keymap.set('n', '<leader>dn', vim.diagnostic.goto_next, opts)
|
||||||
vim.keymap.set('n', 'dl', vim.diagnostic.setloclist, opts)
|
vim.keymap.set('n', '<leader>dl', vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
@@ -46,25 +47,27 @@ local on_attach = function(client, bufnr)
|
|||||||
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
vim.keymap.set('n', 'ld', vim.lsp.buf.declaration, bufopts)
|
vim.keymap.set('n', '<leader>ld', vim.lsp.buf.declaration, bufopts)
|
||||||
--vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
vim.keymap.set('n', '<leader>lD', vim.lsp.buf.definition, bufopts)
|
||||||
--vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
vim.keymap.set('n', '<leader>lh', vim.lsp.buf.hover, bufopts)
|
||||||
--vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
--vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
--vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
vim.keymap.set('n', '<leader>ls', vim.lsp.buf.signature_help, bufopts)
|
||||||
--vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
--vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||||
--vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
--vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||||
--vim.keymap.set('n', '<space>wl', function()
|
--vim.keymap.set('n', '<space>wl', function()
|
||||||
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
--end, bufopts)
|
--end, bufopts)
|
||||||
--vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
--vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||||
vim.keymap.set('n', 'lr', vim.lsp.buf.rename, bufopts)
|
vim.keymap.set('n', '<leader>lr', vim.lsp.buf.rename, bufopts)
|
||||||
vim.keymap.set('n', 'la', vim.lsp.buf.code_action, bufopts)
|
vim.keymap.set('n', '<leader>la', vim.lsp.buf.code_action, bufopts)
|
||||||
--vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
--vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
--vim.keymap.set("n", "<space>f", function()
|
--vim.keymap.set("n", "<space>f", function()
|
||||||
-- vim.lsp.buf.format({ async = true })
|
-- vim.lsp.buf.format({ async = true })
|
||||||
--end, bufopts)
|
--end, bufopts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
-- Configure each language
|
-- Configure each language
|
||||||
-- How to add LSP for a specific language?
|
-- How to add LSP for a specific language?
|
||||||
-- 1. use `:Mason` to install corresponding LSP
|
-- 1. use `:Mason` to install corresponding LSP
|
||||||
@@ -73,5 +76,18 @@ end
|
|||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
lspconfig[lsp].setup {
|
lspconfig[lsp].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, lsp in ipairs(l_servers) do
|
||||||
|
lspconfig[lsp].setup({
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
lspconfig.opts = {
|
||||||
|
servers = {
|
||||||
|
[lsp] = {mason = false,},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ end
|
|||||||
local luasnip = require("luasnip")
|
local luasnip = require("luasnip")
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
vim.keymap.set({ "i", "s" }, "<C-L>", function() luasnip.jump(1) end, { silent = true })
|
||||||
|
vim.keymap.set({ "i", "s" }, "<C-H>", function() luasnip.jump(-1) end, { silent = true })
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
-- REQUIRED - you must specify a snippet engine
|
-- REQUIRED - you must specify a snippet engine
|
||||||
@@ -16,11 +19,11 @@ cmp.setup({
|
|||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
-- Use <C-b/f> to scroll the docs
|
-- Use <C-b/f> to scroll the docs
|
||||||
['K'] = cmp.mapping.scroll_docs(-4),
|
['<C-K>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['J'] = cmp.mapping.scroll_docs(4),
|
['<C-J>'] = cmp.mapping.scroll_docs(4),
|
||||||
-- Use <C-k/j> to switch in items
|
-- Use <C-k/j> to switch in items
|
||||||
['k'] = cmp.mapping.select_prev_item(),
|
['<C-k>'] = cmp.mapping.select_prev_item(),
|
||||||
['j'] = cmp.mapping.select_next_item(),
|
['<C-j>'] = cmp.mapping.select_next_item(),
|
||||||
-- Use <CR>(Enter) to confirm selection
|
-- Use <CR>(Enter) to confirm selection
|
||||||
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||||
@@ -72,8 +75,9 @@ cmp.setup({
|
|||||||
-- Set source precedence
|
-- Set source precedence
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||||
{ name = 'luasnip' }, -- For luasnip user
|
{ name = 'luasnip' }, -- For luasnip user
|
||||||
{ name = 'buffer' }, -- For buffer word completion
|
{ name = 'buffer' }, -- For buffer word completion
|
||||||
{ name = 'path' }, -- For path completion
|
{ name = 'path' }, -- For path completion
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
local onedark = require("onedark")
|
local onedark = require("onedark")
|
||||||
|
|
||||||
onedark.setup {
|
onedark.setup {
|
||||||
style = "darker"
|
style = "darker",
|
||||||
|
highlights = {
|
||||||
|
Comment = {fg = '#F62681'},
|
||||||
|
["@comment"] = {fg = '#F62681'},
|
||||||
|
["@lsp.type.comment"] = {fg = '#F62681'},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
onedark.load()
|
onedark.load()
|
||||||
|
|||||||
Reference in New Issue
Block a user