Compare commits
11 Commits
d0f954b006
...
816c2cddec
Author | SHA1 | Date | |
---|---|---|---|
816c2cddec | |||
734967c967 | |||
5c6e37c287 | |||
5f615e405a | |||
bf7f000533 | |||
f0a8c49074 | |||
7594bbc120 | |||
03a01e2e4c | |||
9cb2f02194 | |||
faf0738b85 | |||
534558cea8 |
@ -1,7 +1,8 @@
|
||||
Yuan Neovim 備忘
|
||||
===
|
||||
## 依賴的套件
|
||||
* tree-sitter
|
||||
* ripgrep 全文搜尋用
|
||||
* tree-sitter 快速且增量式的語法剖析器(parser)
|
||||
* tree-sitter-bash
|
||||
* tree-sitter-cli
|
||||
* imagemagick
|
||||
@ -16,15 +17,13 @@ Yuan Neovim 備忘
|
||||
|
||||
### 擴充自行設定的快速鍵
|
||||
* `<F6>` 可以回朔到開啟檔案以來的任何歷史,還會標出修改的地方
|
||||
* `<F7>` 看看你設定了哪些變數、函數,也可以快速跳轉
|
||||
* `<F8>`: NeoTree: 查看已經開啟的檔案
|
||||
* `<F9>`: NeoTree
|
||||
* `<F10>`: git status
|
||||
* `<leader>fT`: 浮動NeoTree
|
||||
* `<leader>fB`: 已開啟的檔案
|
||||
|
||||
#### 預計設定
|
||||
* <F7> 看看你設定了哪些變數、函數,也可以快速跳轉
|
||||
|
||||
### 編輯習慣(已經覆寫)
|
||||
* shift+方向鍵(傳統): 選取文字(傳統習慣)
|
||||
* PS. 不能用jk是因為 shift+j shift+k有被其他功能綁定,不覆寫是想順便習慣vim用法
|
||||
@ -62,6 +61,28 @@ dot_config/nvim
|
||||
└── Readme.md
|
||||
```
|
||||
|
||||
## LSP -Language Server Protocol
|
||||
因為設定方式與結構太過複雜,故獨立開
|
||||
|
||||
### 和LSP有關的目錄結構
|
||||
```
|
||||
~/.config/nvim/
|
||||
├── lua/
|
||||
│ ├── plugins/
|
||||
│ │ ├── lsp.lua <-- 所有 LSP / cmp 相關 plugin 定義
|
||||
│ ├── lsp/
|
||||
│ │ ├── init.lua <-- 初始化 Mason / LSP 等
|
||||
│ │ ├── config/
|
||||
│ │ │ ├── mason.lua <-- 1. Mason 設定,需要的程式語言安裝都在這定義
|
||||
│ │ │ ├── lspconfig.lua <-- 2. 載入各語言的設定
|
||||
│ │ │ └── cmp.lua <-- nvim-cmp 設定
|
||||
│ │ └── servers/
|
||||
│ │ ├── php.lua
|
||||
│ │ ├── pyright.lua
|
||||
│ │ └── ...
|
||||
│ └──(可另外有 config/、keymaps/ 等其他模組)
|
||||
```
|
||||
|
||||
## 代找外掛
|
||||
* Align
|
||||
*
|
||||
|
@ -55,6 +55,7 @@ return {
|
||||
desc = "NeoTree"
|
||||
},
|
||||
{ "<F8>", "<cmd>Neotree toggle buffers<cr>", desc = "NeoTree Buffers" },
|
||||
{ "<F7>", "<cmd>Neotree document_symbols right toggle<cr>", desc = "NeoTree document_symbols" },
|
||||
|
||||
{ "<leader>e", "<Cmd>Neotree reveal<CR>" },
|
||||
{ "<leader>ft", "<cmd>Neotree toggle<cr>", desc = "NeoTree" },
|
||||
@ -63,12 +64,19 @@ return {
|
||||
{ "<leader>fG", "<cmd>Neotree git_status float<cr>", desc = "NeoTree Git Status Float" },
|
||||
{ "<S-F9>", "<cmd>Neotree git_status float<cr>", desc = "NeoTree Git Status Float" }, --警告!在標準終端無法使用
|
||||
{ "<leader>fB", "<cmd>Neotree buffers float<cr>", desc = "NeoTree Buffers Float" },
|
||||
{ "<leader>fD", "<cmd>Neotree document_symbols float<cr>", desc = "NeoTree Document Symbols Float" },
|
||||
},
|
||||
lazy = false,
|
||||
-----Instead of using `config`, you can use `opts` instead, if you'd like:
|
||||
-----@module "neo-tree"
|
||||
-----@type neotree.Config
|
||||
opts = {
|
||||
sources = {
|
||||
"filesystem",
|
||||
"buffers",
|
||||
"git_status",
|
||||
"document_symbols",
|
||||
},
|
||||
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
|
||||
popup_border_style = "NC", -- or "" to use 'winborder' on Neovim v0.11+
|
||||
enable_git_status = true,
|
||||
@ -182,71 +190,71 @@ return {
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
},
|
||||
mappings = {
|
||||
["<space>"] = {
|
||||
"toggle_node",
|
||||
nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
|
||||
},
|
||||
["<2-LeftMouse>"] = "open",
|
||||
["<cr>"] = "open",
|
||||
["<esc>"] = "cancel", -- close preview or floating neo-tree window
|
||||
["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = false } },
|
||||
-- Read `# Preview Mode` for more information
|
||||
["l"] = "focus_preview",
|
||||
["S"] = "open_split",
|
||||
["s"] = "open_vsplit",
|
||||
-- ["S"] = "split_with_window_picker",
|
||||
-- ["s"] = "vsplit_with_window_picker",
|
||||
["t"] = "open_tabnew",
|
||||
-- ["<cr>"] = "open_drop",
|
||||
-- ["t"] = "open_tab_drop",
|
||||
["w"] = "open_with_window_picker",
|
||||
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
|
||||
["C"] = "close_node",
|
||||
-- ['C'] = 'close_all_subnodes',
|
||||
["z"] = "close_all_nodes",
|
||||
--["Z"] = "expand_all_nodes",
|
||||
--["Z"] = "expand_all_subnodes",
|
||||
["a"] = {
|
||||
"add",
|
||||
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
|
||||
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
|
||||
config = {
|
||||
show_path = "none", -- "none", "relative", "absolute"
|
||||
},
|
||||
},
|
||||
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
|
||||
["d"] = "delete",
|
||||
["r"] = "rename",
|
||||
["b"] = "rename_basename",
|
||||
["y"] = "copy_to_clipboard",
|
||||
["x"] = "cut_to_clipboard",
|
||||
["p"] = "paste_from_clipboard",
|
||||
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
|
||||
-- ["c"] = {
|
||||
-- "copy",
|
||||
-- config = {
|
||||
-- show_path = "none" -- "none", "relative", "absolute"
|
||||
-- }
|
||||
--}
|
||||
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
|
||||
["q"] = "close_window",
|
||||
["R"] = "refresh",
|
||||
["?"] = "show_help",
|
||||
["<"] = "prev_source",
|
||||
[">"] = "next_source",
|
||||
["i"] = "show_file_details",
|
||||
-- ["i"] = {
|
||||
-- "show_file_details",
|
||||
-- -- format strings of the timestamps shown for date created and last modified (see `:h os.date()`)
|
||||
-- -- both options accept a string or a function that takes in the date in seconds and returns a string to display
|
||||
-- -- config = {
|
||||
-- -- created_format = "%Y-%m-%d %I:%M %p",
|
||||
-- -- modified_format = "relative", -- equivalent to the line below
|
||||
-- -- modified_format = function(seconds) return require('neo-tree.utils').relative_date(seconds) end
|
||||
-- -- }
|
||||
-- mappings = {
|
||||
-- ["<space>"] = {
|
||||
-- "toggle_node",
|
||||
-- nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
|
||||
-- },
|
||||
-- ["<2-LeftMouse>"] = "open",
|
||||
-- ["<cr>"] = "open",
|
||||
-- ["<esc>"] = "cancel", -- close preview or floating neo-tree window
|
||||
-- ["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = false } },
|
||||
-- -- Read `# Preview Mode` for more information
|
||||
-- ["l"] = "focus_preview",
|
||||
-- ["S"] = "open_split",
|
||||
-- ["s"] = "open_vsplit",
|
||||
-- -- ["S"] = "split_with_window_picker",
|
||||
-- -- ["s"] = "vsplit_with_window_picker",
|
||||
-- ["t"] = "open_tabnew",
|
||||
-- -- ["<cr>"] = "open_drop",
|
||||
-- -- ["t"] = "open_tab_drop",
|
||||
-- ["w"] = "open_with_window_picker",
|
||||
-- --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
|
||||
-- ["C"] = "close_node",
|
||||
-- -- ['C'] = 'close_all_subnodes',
|
||||
-- ["z"] = "close_all_nodes",
|
||||
-- --["Z"] = "expand_all_nodes",
|
||||
-- --["Z"] = "expand_all_subnodes",
|
||||
-- ["a"] = {
|
||||
-- "add",
|
||||
-- -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
|
||||
-- -- some commands may take optional config options, see `:h neo-tree-mappings` for details
|
||||
-- config = {
|
||||
-- show_path = "none", -- "none", "relative", "absolute"
|
||||
-- },
|
||||
-- },
|
||||
-- ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
|
||||
-- ["d"] = "delete",
|
||||
-- ["r"] = "rename",
|
||||
-- ["b"] = "rename_basename",
|
||||
-- ["y"] = "copy_to_clipboard",
|
||||
-- ["x"] = "cut_to_clipboard",
|
||||
-- ["p"] = "paste_from_clipboard",
|
||||
-- ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
|
||||
-- -- ["c"] = {
|
||||
-- -- "copy",
|
||||
-- -- config = {
|
||||
-- -- show_path = "none" -- "none", "relative", "absolute"
|
||||
-- -- }
|
||||
-- --}
|
||||
-- ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
|
||||
-- ["q"] = "close_window",
|
||||
-- ["R"] = "refresh",
|
||||
-- ["?"] = "show_help",
|
||||
-- ["<"] = "prev_source",
|
||||
-- [">"] = "next_source",
|
||||
-- ["i"] = "show_file_details",
|
||||
-- -- ["i"] = {
|
||||
-- -- "show_file_details",
|
||||
-- -- -- format strings of the timestamps shown for date created and last modified (see `:h os.date()`)
|
||||
-- -- -- both options accept a string or a function that takes in the date in seconds and returns a string to display
|
||||
-- -- -- config = {
|
||||
-- -- -- created_format = "%Y-%m-%d %I:%M %p",
|
||||
-- -- -- modified_format = "relative", -- equivalent to the line below
|
||||
-- -- -- modified_format = function(seconds) return require('neo-tree.utils').relative_date(seconds) end
|
||||
-- -- -- }
|
||||
-- -- },
|
||||
-- },
|
||||
},
|
||||
},
|
||||
nesting_rules = {},
|
||||
filesystem = {
|
||||
@ -383,6 +391,87 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
document_symbols = {
|
||||
follow_cursor = true,
|
||||
client_filters = "first",
|
||||
renderers = {
|
||||
root = {
|
||||
{"indent"},
|
||||
{"icon", default="C" },
|
||||
{"name", zindex = 10},
|
||||
},
|
||||
symbol = {
|
||||
{"indent", with_expanders = true},
|
||||
{"kind_icon", default="?" },
|
||||
{"container",
|
||||
content = {
|
||||
{"name", zindex = 10},
|
||||
{"kind_name", zindex = 20, align = "right"},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
window = {
|
||||
mappings = {
|
||||
["<cr>"] = "jump_to_symbol",
|
||||
["o"] = "jump_to_symbol",
|
||||
["A"] = "noop", -- also accepts the config.show_path and config.insert_as options.
|
||||
["d"] = "noop",
|
||||
["y"] = "noop",
|
||||
["x"] = "noop",
|
||||
["p"] = "noop",
|
||||
["c"] = "noop",
|
||||
["m"] = "noop",
|
||||
["a"] = "noop",
|
||||
["/"] = "filter",
|
||||
["f"] = "filter_on_submit",
|
||||
},
|
||||
},
|
||||
custom_kinds = {
|
||||
-- define custom kinds here (also remember to add icon and hl group to kinds)
|
||||
-- ccls
|
||||
-- [252] = 'TypeAlias',
|
||||
-- [253] = 'Parameter',
|
||||
-- [254] = 'StaticMethod',
|
||||
-- [255] = 'Macro',
|
||||
},
|
||||
kinds = {
|
||||
Unknown = { icon = "?", hl = "" },
|
||||
Root = { icon = "", hl = "NeoTreeRootName" },
|
||||
File = { icon = "", hl = "Tag" },
|
||||
Module = { icon = "", hl = "Exception" },
|
||||
Namespace = { icon = "", hl = "Include" },
|
||||
Package = { icon = "", hl = "Label" },
|
||||
Class = { icon = "", hl = "Include" },
|
||||
Method = { icon = "", hl = "Function" },
|
||||
Property = { icon = "", hl = "@property" },
|
||||
Field = { icon = "", hl = "@field" },
|
||||
Constructor = { icon = "", hl = "@constructor" },
|
||||
Enum = { icon = "", hl = "@number" },
|
||||
Interface = { icon = "", hl = "Type" },
|
||||
Function = { icon = "", hl = "Function" },
|
||||
Variable = { icon = "", hl = "@variable" },
|
||||
Constant = { icon = "", hl = "Constant" },
|
||||
String = { icon = "", hl = "String" },
|
||||
Number = { icon = "", hl = "Number" },
|
||||
Boolean = { icon = "", hl = "Boolean" },
|
||||
Array = { icon = "", hl = "Type" },
|
||||
Object = { icon = "", hl = "Type" },
|
||||
Key = { icon = "", hl = "" },
|
||||
Null = { icon = "", hl = "Constant" },
|
||||
EnumMember = { icon = "", hl = "Number" },
|
||||
Struct = { icon = "", hl = "Type" },
|
||||
Event = { icon = "", hl = "Constant" },
|
||||
Operator = { icon = "", hl = "Operator" },
|
||||
TypeParameter = { icon = "", hl = "Type" },
|
||||
|
||||
-- ccls
|
||||
-- TypeAlias = { icon = ' ', hl = 'Type' },
|
||||
-- Parameter = { icon = ' ', hl = '@parameter' },
|
||||
-- StaticMethod = { icon = ' ', hl = 'Function' },
|
||||
-- Macro = { icon = ' ', hl = 'Macro' },
|
||||
}
|
||||
},
|
||||
|
||||
-- 自行加入的
|
||||
source_selector = {
|
||||
|
@ -7,6 +7,7 @@ return {
|
||||
lazy = false,
|
||||
keys = {
|
||||
{ "<C-p>", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<C-S-F>", "<cmd>Telescope live_grep<cr>", desc = "Grep" }, -- 僅限GUI
|
||||
|
||||
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Grep" },
|
||||
|
@ -2,18 +2,14 @@
|
||||
|
||||
return {
|
||||
'dstein64/nvim-scrollview',
|
||||
setup = function()
|
||||
config = function()
|
||||
require('scrollview').setup({
|
||||
-- Default options
|
||||
current_only = true, -- Only show scroll indicator in current window
|
||||
winblend = 0, -- Blend of the scroll indicator
|
||||
-- base = 1, -- Base value for the scroll indicator
|
||||
-- max_lines = 1000, -- Maximum number of lines to show the scroll indicator
|
||||
excluded_filetypes = { 'help', 'neo-tree' }, -- Filetypes to exclude from showing the scroll indicator
|
||||
base = 'buffer',
|
||||
-- column = 80,
|
||||
signs_on_startup = {'all'},
|
||||
diagnostics_severities = {vim.diagnostic.severity.ERROR}
|
||||
current_only = true,
|
||||
-- base = 'buffer',
|
||||
-- column = 80, -- 註解掉這行,讓它自己決定位置
|
||||
-- excluded_filetypes = { 'neo-tree', 'help' },
|
||||
signs_on_startup = { 'all' },
|
||||
diagnostics_severities = { vim.diagnostic.severity.ERROR },
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
50
dot_config/nvim/exact_lua/exact_plugins/lsp.lua
Normal file
50
dot_config/nvim/exact_lua/exact_plugins/lsp.lua
Normal file
@ -0,0 +1,50 @@
|
||||
-- 專責 LSP / 補全相關 plugin 定義
|
||||
return {
|
||||
-- 依照mason官方教學抄過來 https://github.com/williamboman/mason-lspconfig.nvim
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
-- 補全相關
|
||||
-- 以下為 hrsh7th/nvim-cmp 的官方範例
|
||||
-- call plug#begin(s:plug_dir)
|
||||
-- Plug 'neovim/nvim-lspconfig'
|
||||
-- Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
-- Plug 'hrsh7th/cmp-buffer'
|
||||
-- Plug 'hrsh7th/cmp-path'
|
||||
-- Plug 'hrsh7th/cmp-cmdline'
|
||||
-- Plug 'hrsh7th/nvim-cmp'
|
||||
|
||||
-- " For vsnip users.
|
||||
-- Plug 'hrsh7th/cmp-vsnip'
|
||||
-- Plug 'hrsh7th/vim-vsnip'
|
||||
|
||||
-- " For luasnip users.
|
||||
-- " Plug 'L3MON4D3/LuaSnip'
|
||||
-- " Plug 'saadparwaiz1/cmp_luasnip'
|
||||
|
||||
-- " For mini.snippets users.
|
||||
-- " Plug 'echasnovski/mini.snippets'
|
||||
-- " Plug 'abeldekat/cmp-mini-snippets'
|
||||
|
||||
-- " For ultisnips users.
|
||||
-- " Plug 'SirVer/ultisnips'
|
||||
-- " Plug 'quangnguyen30192/cmp-nvim-ultisnips'
|
||||
|
||||
-- " For snippy users.
|
||||
-- " Plug 'dcampos/nvim-snippy'
|
||||
-- " Plug 'dcampos/cmp-snippy'
|
||||
|
||||
-- call plug#end()
|
||||
{ "hrsh7th/cmp-nvim-lsp" },
|
||||
{ "hrsh7th/cmp-buffer" },
|
||||
{ "hrsh7th/cmp-path" },
|
||||
{ "hrsh7th/cmp-cmdline" },
|
||||
{ "hrsh7th/nvim-cmp" },
|
||||
|
||||
-- " For luasnip users.
|
||||
{ "L3MON4D3/LuaSnip" },
|
||||
{ "saadparwaiz1/cmp_luasnip" },
|
||||
|
||||
{ "rafamadriz/friendly-snippets" },
|
||||
}
|
@ -3,5 +3,6 @@ require("config.options")
|
||||
require("config.keymaps_nvim")
|
||||
require("config.keymaps")
|
||||
require("config.gui")
|
||||
require("config.lazy")
|
||||
require("config.lazy") -- 初始化 Lazy.nvim
|
||||
require("lsp") -- LSP 與 cmp 設定
|
||||
require("config.terminal") -- 因為會被lazy.nvim override,所以要放在最後
|
||||
|
84
dot_config/nvim/exact_lua/lsp/exact_config/cmp.lua
Normal file
84
dot_config/nvim/exact_lua/lsp/exact_config/cmp.lua
Normal file
@ -0,0 +1,84 @@
|
||||
-- Set up nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
-- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
|
||||
|
||||
-- For `mini.snippets` users:
|
||||
-- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
|
||||
-- insert({ body = args.body }) -- Insert at cursor
|
||||
-- cmp.resubscribe({ "TextChangedI", "TextChangedP" })
|
||||
-- require("cmp.config").set_onetime({ sources = {} })
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
|
||||
-- AI範例:
|
||||
-- ["<Tab>"] = cmp.mapping.select_next_item(),
|
||||
-- ["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
||||
-- ["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below
|
||||
-- Set configuration for specific filetype.
|
||||
--[[ cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
require("cmp_git").setup() ]]--
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false }
|
||||
})
|
||||
|
||||
-- 已經由lspconfig.lua來處理,故註解掉
|
||||
-- -- Set up lspconfig.
|
||||
-- local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
-- -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||
-- require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
|
||||
-- capabilities = capabilities
|
||||
-- }
|
37
dot_config/nvim/exact_lua/lsp/exact_config/lspconfig.lua
Normal file
37
dot_config/nvim/exact_lua/lsp/exact_config/lspconfig.lua
Normal file
@ -0,0 +1,37 @@
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local on_attach = function(_, bufnr)
|
||||
local map = function(mode, lhs, rhs)
|
||||
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr })
|
||||
end
|
||||
map("n", "gd", vim.lsp.buf.definition)
|
||||
map("n", "K", vim.lsp.buf.hover)
|
||||
end
|
||||
|
||||
-- 程式語言所需要的與語言伺服器名稱對照表
|
||||
-- <https://wiki.archlinux.org/title/Language_Server_Protocol>
|
||||
local servers = {
|
||||
"phpactor", -- PHP
|
||||
"sqls", -- SQL
|
||||
"pyright", -- Python
|
||||
"gopls", -- Go
|
||||
"html", -- HTML
|
||||
"cssls", -- CSS
|
||||
"volar", -- Vue3
|
||||
-- "ts_ls", -- TypeScript,目前暫時不需要,先註解掉
|
||||
"marksman", -- Markdown
|
||||
"yamlls", -- YAML
|
||||
}
|
||||
|
||||
-- 載入所有的對應的 LSP server 設定
|
||||
--
|
||||
-- 相關設定請看
|
||||
-- <https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md>
|
||||
for _, name in ipairs(servers) do
|
||||
local ok, config = pcall(require, "lsp.servers." .. name)
|
||||
if not ok then config = {} end
|
||||
config.capabilities = capabilities
|
||||
config.on_attach = on_attach
|
||||
lspconfig[name].setup(config)
|
||||
end
|
39
dot_config/nvim/exact_lua/lsp/exact_config/mason.lua
Normal file
39
dot_config/nvim/exact_lua/lsp/exact_config/mason.lua
Normal file
@ -0,0 +1,39 @@
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup {
|
||||
-- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "lua_ls" }
|
||||
-- This setting has no relation with the `automatic_installation` setting.
|
||||
---@type string[]
|
||||
ensure_installed = {
|
||||
-- "lua_ls", "rust_analyzer" -- 官方範例
|
||||
"phpactor",
|
||||
"sqls",
|
||||
"pyright",
|
||||
"gopls",
|
||||
"html",
|
||||
"cssls",
|
||||
"volar",
|
||||
-- "ts_ls",
|
||||
"marksman",
|
||||
"yamlls",
|
||||
},
|
||||
|
||||
-- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed.
|
||||
-- This setting has no relation with the `ensure_installed` setting.
|
||||
-- Can either be:
|
||||
-- - false: Servers are not automatically installed.
|
||||
-- - true: All servers set up via lspconfig are automatically installed.
|
||||
-- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed.
|
||||
-- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } }
|
||||
---@type boolean
|
||||
automatic_installation = false,
|
||||
|
||||
-- See `:h mason-lspconfig.setup_handlers()`
|
||||
---@type table<string, fun(server_name: string)>?
|
||||
handlers = nil,
|
||||
}
|
||||
|
||||
-- 下面這段先註解掉,由lspconfig.lua來處理
|
||||
-- -- After setting up mason-lspconfig you may set up servers via lspconfig
|
||||
-- require("lspconfig").lua_ls.setup {}
|
||||
-- require("lspconfig").rust_analyzer.setup {}
|
||||
-- -- ...
|
19
dot_config/nvim/exact_lua/lsp/exact_servers/cssls.lua
Normal file
19
dot_config/nvim/exact_lua/lsp/exact_servers/cssls.lua
Normal file
@ -0,0 +1,19 @@
|
||||
return {
|
||||
cmd = { "vscode-css-language-server", "--stdio" },
|
||||
filetypes = { "css", "scss", "less" },
|
||||
init_options = {
|
||||
provideFormatter = true
|
||||
},
|
||||
root_markers = { "package.json", ".git" },
|
||||
settings = {
|
||||
css = {
|
||||
validate = true
|
||||
},
|
||||
less = {
|
||||
validate = true
|
||||
},
|
||||
scss = {
|
||||
validate = true
|
||||
}
|
||||
},
|
||||
}
|
14
dot_config/nvim/exact_lua/lsp/exact_servers/html.lua
Normal file
14
dot_config/nvim/exact_lua/lsp/exact_servers/html.lua
Normal file
@ -0,0 +1,14 @@
|
||||
return {
|
||||
cmd = { "vscode-html-language-server", "--stdio" },
|
||||
filetypes = { "html", "templ" },
|
||||
init_options = {
|
||||
configurationSection = { "html", "css", "javascript" },
|
||||
embeddedLanguages = {
|
||||
css = true,
|
||||
javascript = true
|
||||
},
|
||||
provideFormatter = true
|
||||
},
|
||||
root_markers = { "package.json", ".git" },
|
||||
settings = {},
|
||||
}
|
5
dot_config/nvim/exact_lua/lsp/exact_servers/marksman.lua
Normal file
5
dot_config/nvim/exact_lua/lsp/exact_servers/marksman.lua
Normal file
@ -0,0 +1,5 @@
|
||||
return {
|
||||
cmd = { "marksman", "server" },
|
||||
filetypes = { "markdown", "markdown.mdx" },
|
||||
root_markers = { ".marksman.toml", ".git" },
|
||||
}
|
20
dot_config/nvim/exact_lua/lsp/exact_servers/phpactor.lua
Normal file
20
dot_config/nvim/exact_lua/lsp/exact_servers/phpactor.lua
Normal file
@ -0,0 +1,20 @@
|
||||
return {
|
||||
cmd = { "phpactor", "language-server" },
|
||||
filetypes = { "php" },
|
||||
init_options = {
|
||||
["language_server_phpstan.enabled"] = true,
|
||||
["language_server_psalm.enabled"] = false,
|
||||
},
|
||||
-- 可選:如有額外設定
|
||||
-- settings = {
|
||||
-- -- 這裡可以填寫 phpactor 的其他設定
|
||||
-- },
|
||||
}
|
||||
|
||||
-- 僅對照用
|
||||
-- require("lspconfig").phpactor.setup({
|
||||
-- init_options = {
|
||||
-- ["language_server_phpstan.enabled"] = true,
|
||||
-- ["language_server_psalm.enabled"] = false,
|
||||
-- }
|
||||
-- })
|
14
dot_config/nvim/exact_lua/lsp/exact_servers/pyright.lua
Normal file
14
dot_config/nvim/exact_lua/lsp/exact_servers/pyright.lua
Normal file
@ -0,0 +1,14 @@
|
||||
return {
|
||||
cmd = { "pyright-langserver", "--stdio" },
|
||||
filetypes = { "python" },
|
||||
root_markers = { "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json", ".git" },
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = "openFilesOnly",
|
||||
useLibraryCodeForTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
6
dot_config/nvim/exact_lua/lsp/exact_servers/sqls.lua
Normal file
6
dot_config/nvim/exact_lua/lsp/exact_servers/sqls.lua
Normal file
@ -0,0 +1,6 @@
|
||||
return {
|
||||
cmd = { "sqls" },
|
||||
filetypes = { "sql", "mysql" },
|
||||
root_markers = { "config.yml" },
|
||||
settings = {},
|
||||
}
|
10
dot_config/nvim/exact_lua/lsp/exact_servers/volar.lua
Normal file
10
dot_config/nvim/exact_lua/lsp/exact_servers/volar.lua
Normal file
@ -0,0 +1,10 @@
|
||||
return {
|
||||
cmd = { "vue-language-server", "--stdio" },
|
||||
filetypes = { "vue" },
|
||||
init_options = {
|
||||
typescript = {
|
||||
tsdk = ""
|
||||
}
|
||||
},
|
||||
root_markers = { "package.json" },
|
||||
}
|
12
dot_config/nvim/exact_lua/lsp/exact_servers/yamlls.lua
Normal file
12
dot_config/nvim/exact_lua/lsp/exact_servers/yamlls.lua
Normal file
@ -0,0 +1,12 @@
|
||||
return {
|
||||
cmd = { "yaml-language-server", "--stdio" },
|
||||
filetypes = { "yaml", "yaml.docker-compose", "yaml.gitlab" },
|
||||
root_markers = { ".git" },
|
||||
settings = {
|
||||
redhat = {
|
||||
telemetry = {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
3
dot_config/nvim/exact_lua/lsp/init.lua
Normal file
3
dot_config/nvim/exact_lua/lsp/init.lua
Normal file
@ -0,0 +1,3 @@
|
||||
require("lsp.config.mason")
|
||||
require("lsp.config.lspconfig")
|
||||
require("lsp.config.cmp")
|
@ -151,6 +151,9 @@ zle -N my_paste_from_clipboard
|
||||
# bindkey '^O' my_paste_from_clipboard # 例如 Ctrl+O
|
||||
bindkey '^P' my_paste_from_clipboard # 例如 Ctrl+P
|
||||
|
||||
# SSH 自動補齊
|
||||
zinit light sunlei/zsh-ssh
|
||||
|
||||
# overwrite ls
|
||||
if command -v colorls &> /dev/null; then
|
||||
alias ls='colorls'
|
||||
|
Loading…
x
Reference in New Issue
Block a user