Add keymap to delete line with selected word in the file and configure lspkind symbols

This commit is contained in:
PeteChu 2023-04-09 13:33:55 +07:00
parent ef91f14af8
commit a9de446ed3
6 changed files with 99 additions and 18 deletions

View File

@ -55,6 +55,9 @@ keymap("n", "<leader>ch", "<cmd>silent !tmux neww tmux-cht.sh<CR>", { desc = "[C
-- replace selected word in the file -- replace selected word in the file
keymap("n", "<leader>R", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = "[R]eplace words in the file" }) keymap("n", "<leader>R", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = "[R]eplace words in the file" })
-- delete line with selected in the file
keymap("n", "<leader>dl", [[:g/\<<C-r><C-w>\>/d]],
{ desc = "[D]elete [L]ine with selected word in the file" })
-- Make file executable -- Make file executable
keymap("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Make [X]ecutable file" }) keymap("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Make [X]ecutable file" })

47
after/plugin/lspkind.lua Normal file
View File

@ -0,0 +1,47 @@
require('lspkind').init({
-- DEPRECATED (use mode instead): enables text annotations
--
-- default: true
-- with_text = true,
-- defines how annotations are shown
-- default: symbol
-- options: 'text', 'text_symbol', 'symbol_text', 'symbol'
mode = 'symbol_text',
-- default symbol map
-- can be either 'default' (requires nerd-fonts font) or
-- 'codicons' for codicon preset (requires vscode-codicons font)
--
-- default: 'default'
preset = 'codicons',
-- override preset symbols
--
-- default: {}
symbol_map = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
},
})

View File

@ -186,7 +186,7 @@ require('lazy').setup({
end, end,
}, },
{ {
"glepnir/lspsaga.nvim", "glepnir/lspsaga.nvim",
event = "LspAttach", event = "LspAttach",
dependencies = { dependencies = {
@ -195,10 +195,18 @@ require('lazy').setup({
{ "nvim-treesitter/nvim-treesitter" } { "nvim-treesitter/nvim-treesitter" }
}, },
config = function() config = function()
require("lspsaga").setup({}) require("lspsaga").setup {
lightbulb = {
enable = false
},
request_timeout = 5000
}
end, end,
}, },
{ "onsails/lspkind.nvim" },
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository. -- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them. -- Uncomment any of the lines below to enable them.
@ -315,7 +323,8 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
-- See `:help nvim-treesitter` -- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter -- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim', 'markdown', 'markdown_inline' }, ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim', 'markdown',
'markdown_inline' },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true, auto_install = true,
@ -433,9 +442,13 @@ local on_attach = function(_, bufnr)
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders') end, '[W]orkspace [L]ist Folders')
-- Toggle outline -- Toggle outline
nkeymap("<leader>o", ":Lspsaga outline<CR>", '[O]utline') nmap("<leader>o", ":Lspsaga outline<CR>", '[O]utline')
-- Show cursor diagnostic
-- nmap("<S-f>", ":Lspsaga show_cursor_diagnostics<CR>", 'Show cursor diagnostics')
nmap("<S-f>", ":Lspsaga show_line_diagnostics<CR>", 'Show cursor diagnostics')
-- Create a command `:Format` local to the LSP buffer -- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
@ -454,7 +467,18 @@ local servers = {
-- pyright = {}, -- pyright = {},
-- rust_analyzer = {}, -- rust_analyzer = {},
-- tsserver = {}, -- tsserver = {},
efm = {
init_options = { documentFormatting = true },
settings = {
rootMarkers = { ".git/" },
languages = {
prettier = {
formatCommand = 'prettierd "${INPUT}"',
formatStdin = true,
}
}
}
},
lua_ls = { lua_ls = {
Lua = { Lua = {
workspace = { checkThirdParty = false }, workspace = { checkThirdParty = false },
@ -493,6 +517,7 @@ mason_lspconfig.setup_handlers {
-- nvim-cmp setup -- nvim-cmp setup
local cmp = require 'cmp' local cmp = require 'cmp'
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
local lspkind = require 'lspkind'
luasnip.config.setup {} luasnip.config.setup {}
@ -534,6 +559,11 @@ cmp.setup {
{ name = 'luasnip' }, { name = 'luasnip' },
{ name = 'buffer' }, { name = 'buffer' },
}, },
formatting = {
format = lspkind.cmp_format({
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
})
}
} }
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`

View File

@ -1,12 +0,0 @@
return {
"jose-elias-alvarez/null-ls.nvim",
config = function()
local null_ls = require("null-ls")
null_ls.setup({
source = {
null_ls.builtins.diagnostics.eslint,
null_ls.builtins.completion.spell,
}
})
end
}

View File

@ -0,0 +1,7 @@
return {
"folke/todo-comments.nvim",
requires = "nvim-lua/plenary.nvim",
config = function()
require("todo-comments").setup()
end
}

View File

@ -0,0 +1,6 @@
return {
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup()
end
}